スクリプト
いつものように妄想という名の遊び。
バイトコード
スクリプトを解析後,変換されるバイトコード。
命令長が多少長くなっても,1命令で処理される内容が多い方がよいだろう。
./言語仕様
./バイトコード
./オレ言語を作ってみたい人へ
アセンブラ言語
オペランド
- num - 値
頭に何も付けず数値,この場合は10進数表記。
もしくは頭にb,d,h,xを付ける。
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| #spanend
#spandel
// 10進数表記
#spanend
#spandel
copy bp[-4] 12345
#spanend
#spandel
copy bp[-4] d12345
#spanend
#spandel
// 2進数表記
#spanend
#spandel
copy bp[-4] b0001
#spanend
#spandel
// 8進数表記
#spanend
#spandel
copy bp[-4] h7543
#spanend
#spandel
// 16進数表記
#spanend
#spandel
copy bp[-4] x0123ABCD
#spanend
#spandel
|
./メモ
- @ - シンボル
シンボル名に使っていい文字列は[a-zA-Z0-9_]。ただし1文字目に数値は使えない。
宣言するときはシンボル名の後に:。
参照するときは頭に@を付け,その後シンボル名。
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| #spanend
#spandel
VALUE_ONE:
#spanend
s32 1
#spanadd
#code(D,){{
#spanend
#spanadd
//-----------------------------------------------------------
#spanend
#spanadd
module Project.Util.Vector3;
#spanend
#spandel
func:
#spanend
copy bp[-4] @VALUE_ONE[0]
#spandel
|
using Std.Math;
- bp - ベースポインタレジスタ
スタック上のベースとなる位置。
0
1
2
3
4
| #spanend
#spandel
func:
#spanend
copy bp[-4] 1
#spandel
|
- * - アドレス先の値を受け取る
bp,もしくは@の前に*。
0
1
2
3
4
| #spanend
#spandel
func:
#spanend
copy bp[-4] *bp[-8]
#spandel
|
- & - アドレス値を受け取る
bp,もしくは@の前に&。
0
1
2
3
4
| #spanend
#spandel
func:
#spanend
copy bp[-4] &bp
#spandel
|
- 相対アドレスの指定
bp,もしくは@の後ろに[数値]で指定。
省略したら[0]と等価。
命令
copy - 代入
C言語で書くとdest = src。
copy1 dest src
copy2 dest src
copy4 dest src
copy8 dest src
メモ
データの指定。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
-
|
|
|
|
|
|
-
|
!
|
|
|
|
|
|
!
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
| #spanend
#spandel
#spanend
#spandel
const int CONST_VALUE = 1;
#spanend
#spandel
const int* CONST_VALUE_ADDR = &CONST_VALUE;
#spanend
#spandel
#spanend
#spandel
struct Pos
#spanend
#spanadd
#spanend
#spanadd
pod Vector3
#spanend
{
int x;
int y;
#spanadd
public:
#spanend
float length()const
{
return Math.Sqrt( x*x + y*y + z*z );
}
#spanadd
#spanend
float x;
float y;
float z;
};
#spandel
const Pos CONST_OBJ_VALUE = {0,0};
#spanend
#spandel
const Pos* CONST_OBJ_VALUE_ADDR = &CONST_OBJ_VALUE;
#spanend
#spandel
void func()
#spanend
#spandel
{
#spanend
int stack_value;
int* stack_value_ptr:
#spandel
#spanend
int i;
i = 1;
#spandel
#spanend
i = *CONST_VALUE_ADDR;
#spandel
#spanend
i = CONST_OBJ_VALUE.y;
#spandel
#spanend
i = stack_value;
#spandel
#spanend
stack_value_addr = &stack_value;
#spandel
#spanend
i = *stack_value_ptr;
#spandel
}
#spanend
#spanadd
#spanend
#spanadd
#spanend
|
|