虚拟指令意义 (括号内代码为注释。名称下的为同义代码,有相同的意思,主要是为了wqx里书写方便)
名称 寻址方式 字节码 代码格式 伪代码表示
1.ph1 立即 ph1 #NUM [SP]<-NUM,0,0,0; SP+=4; (栈单元大小为4bytes,不够的部分用0补齐,下同)
(phs) 直接 ph1 ADDR [SP]<-{ADDR},0,0,0; SP+=4;
环境 ph1 oADDR [SP]<-{ADDR+EP},0,0,0; SP+=4;
2.ph2 立即 ph2 #NUM [SP]<-NUM,0,0; SP+=4;
(phd) 直接 ph2 ADDR [SP]<-{ADDR},{ADDR+1},0,0; SP+=4;
环境 ph2 oADDR [SP]<-{ADDR+EP},{ADDR+EP+1},0,0; SP+=4;
3.ph4 立即 ph4 #NUM [SP]<-NUM; SP+=4;
(phq) 直接 ph4 ADDR [SP]<-{ADDR},{ADDR+1},{ADDR+2},{ADDR+3}; SP+=4;
环境 ph4 oADDR [SP]<-{ADDR+EP},{ADDR+EP+1},{ADDR+EP+2},{ADDR+EP+3}; SP+=4;
4.ph1i 直接 ph1i ADDR [SP-4]<-{[SP-4]+ADDR},0,0,0;
(phsi) 环境 ph1i oADDR [SP-4]<-{[SP-4]+ADDR+EP},0,0,0;
5.ph2i 直接 ph2i ADDR [SP-4]<-{[SP-4]+ADDR},{[SP-4]+ADDR+1},0,0;
(phdi) 环境 ph2i oADDR [SP-4]<-{[SP-4]+ADDR+EP},{[SP-4]+ADDR+EP+1},0,0;
6.ph4i 直接 ph4i ADDR [SP-4]<-{[SP-4]+ADDR},{[SP-4]+ADDR+1},{[SP-4]+ADDR+2},{[SP-4]+ADDR+3};
(phqi) 环境 ph4i oADDR [SP-4]<-{[SP-4]+ADDR+EP},{[SP-4]+ADDR+EP+1},{[SP-4]+ADDR+EP+2},{[SP-4]+ADDR+EP+3};
7.ah1 直接 ah1 ADDR [SP-4]<-[SP-4]+ADDR(2bytes),01,0;
(ahs) 环境 ah1 oADDR [SP-4]<-[SP-4]+ADDR(2bytes),81,0;
8.ah2 直接 ah2 ADDR [SP-4]<-[SP-4]+ADDR(2bytes),02,0;
(ahs) 环境 ah2 oADDR [SP-4]<-[SP-4]+ADDR(2bytes),82,0;
9.ah4 直接 ah4 ADDR [SP-4]<-[SP-4]+ADDR(2bytes),04,0;
(ahs) 环境 ah4 oADDR [SP-4]<-[SP-4]+ADDR(2bytes),84,0;
10.ada 直接 ada ADDR [SP-4]<-[SP-4]+ADDR(2bytes),0,0;
11.?
12.tabs 环境 tabs oADDR [SP-4]<-[SP-4]+EP(2bytes),0,0;
13.add 隐含 add [SP-8]<-[SP-8]+[SP-4]; SP-=4;
立即 add #NUM [SP-4]<-[SP-4]+NUM(4byte);
14.mns 隐含 add [SP-8]<-[SP-8]-[SP-4]; SP-=4;
立即 add #NUM [SP-4]<-[SP-4]-NUM(4byte);
15.mul 隐含 add [SP-8]<-[SP-8]*[SP-4]; SP-=4;
立即 add #NUM [SP-4]<-[SP-4]*NUM(4byte);
16.div 隐含 add [SP-8]<-[SP-8]\[SP-4]; SP-=4; ( "\"表示整除 )
立即 add #NUM [SP-4]<-[SP-4]\NUM(4byte);
17.mod 隐含 add [SP-8]<-[SP-8]%[SP-4]; SP-=4; ( "%"表示取余 )
立即 add #NUM [SP-4]<-[SP-4]%NUM(4byte);
18.band 隐含 band [SP-8]<-[SP-8]&[SP-4](4byte);SP-=4; ("&"表示位与)
19.bor 隐含 bor [SP-8]<-[SP-8]|[SP-4](4byte);SP-=4; ("|"表示位或)
20.bopp.? (不会用 )
21.bxor 隐含 bxor [SP-8]<-[SP-8]^[SP-4](4byte);SP-=4; ("^"表示位异或)
22.phn 立即 phn DATA [aPlace]<-DATA;[SP]<-aPlace(4bytes);SP+=4; ("aPlace"表示一个地方,具体在哪不知道")
23.and 隐含 and [SP-8]<-[SP-8]&&[SP-4](4bytes);SP-=4;
24.or 隐含 or [SP-8]<-[SP-8]||[SP-4](4bytes);SP-=4;
25.not 隐含 not [SP-4]<-![SP-4](4bytes);
26.more 立即 more #NUM [SP-4]<-[SP-4]>NUM(2bytes); (如果为真,是-1,假为0)
隐含 more [SP-8]<-[SP-8]>[SP-4](4bytes);SP-=4;
27.less 立即 less #NUM [SP-4]<-[SP-4]<NUM(2bytes);
隐含 less [SP-8]<-[SP-8]<[SP-4](4bytes);SP-=4;
28.equ 立即 equ #NUM [SP-4]<-[SP-4]==NUM(2bytes);
隐含 equ [SP-8]<-[SP-8]==[SP-4](4bytes);SP-=4;
29.neq 立即 neq #NUM [SP-4]<-[SP-4]!=NUM(2bytes);
隐含 neq [SP-8]<-[SP-8]!=[SP-4](4bytes);SP-=4;
30.nmor 立即 nmor #NUM [SP-4]<-[SP-4]<=NUM(2bytes);
隐含 nmor [SP-8]<-[SP-8]<=[SP-4](4bytes);SP-=4;
32.nles 立即 nles #NUM [SP-4]<-[SP-4]>=NUM(2bytes);
隐含 nles [SP-8]<-[SP-8]>=[SP-4](4bytes);SP-=4;
33.neg 隐含 neg [SP-4]<- -[SP-4];
33.mvl 立即 mvl #NUM [SP-4]<-[SP-4]<<NUM(2bytes);
隐含 mvl [SP-8]<-[SP-8]<<[SP-4](4bytes);SP-=4;
34.mvr 立即 mvr #NUM [SP-4]<-[SP-4]>>NUM(2bytes);
隐含 mvr [SP-8]<-[SP-8]>>[SP-4](4bytes);SP-=4;
35.base 直接 base ADDR EP=ADDR;
36.pop 隐含 pop SP-=4;
37.ret 隐含 ret NEP<-EP;PC<-{EP},{EP+1},{EP+2};EP<-{EP+3},{EP+4};
38.goto 直接 goto ADDR PC<- ADDR(3bytes) (此处的ADDR表示读lava文件的指针,为3bytes)
39.func 立即 func ADDR1(2byte),ADDR2(1byte) EQ<-NEQ;NEQ<-NEQ+ADDR1;把ADDR2个参数从栈中移到环境
里
40.call 直接 call ADDR {NEP}<-PC;PC<- ADDR(3bytes) (此处的ADDR表示读lava文件的指针,为3bytes)
44 =#loadall
45 XXYY =push4B #(pop4B+0x0000XXYY)
46 XXYY =push4B #(pop4B-0x0000XXYY)
47 XXYY =push4B #(pop4B*0x0000XXYY)
48 XXYY =push4B #(pop4B\0x0000XXYY)
49 XXYY =push4B #(pop4B%0x0000XXYY)
4A XXYY =push4B #(pop4B<<0x0000XXYY)
4B XXYY =push4B #(pop4B>>0x0000XXYY)
4C XXYY =push4B #(pop4B==XXXX)
4D XXYY =push4B #(pop4B!=XXXX)
4E XXYY =push4B #(pop4B>XXXX)
4F XXYY =push4B #(pop4B<XXXX)
50 XXYY =push4B #(pop4B>=XXXX)
51 XXYY =push4B #(pop4B<=XXXX)
80 =putchar
81 =getchar
82 =printf
83 =strcpy
84 =strlen
85 =SetScreen
86 =UpdateLCD
87 =Delay
88 =WriteBlock
89 =Refresh
8A =TextOut
8B =Block
8C =Rectangle
8D =exit();
8E =ClearScreen
8F =abs();
90 =rand();
91 =srand();
92 =Locate
93 =Inkey();
94 =Point
95 =GetPoint
96 =Line
97 =Box
98 =Circle
99 =Ellipse
9A =Beep();
9B =isalnum
9C =isalpha
9D =iscntrl
9E =isdigit
9F =isgraph
A0 =islower
A1 =isprint
A2 =ispunct
A3 =isspace
A4 =isupper
A5 =isxdigit
A6 =strcat
A7 =strchr
A8 =strcmp
A9 =strstr
AA =tolower
AB =toupper
AC =memset();
AD =memcpy();
AE =fopen
AF =fclose
B0 =fread
B1 =fwrite
B2 =fseek
B3 =ftell
B4 =feof
B5 =rewind
B6 =getc
B7 =putc
B8 =sprintf
B9 =MakeDir
BA =DeleteFile
BB =Getms
BC =CheckKey
BD =memmove
BE =Crc16
BF =Secret
C0 =ChDir
C1 =FileList
C2 =GetTime
C3 =SetTime
C4 =GetWord
C5 =XDraw
C6 =ReleaseKey
C7 =GetBlock
C8 =Sin
C9 =Cos
CA =FillArea
Lava虚拟机由以下结构组成:
1 寄存器
Pc寄存器:3bytes
S 堆栈指针寄存器 2bytes
E 环境寄存器
2 指令执行模块
3 堆栈 每个堆栈元素为4bytes固定不变
寻址方式
直接 Operand addr e.g. ph1 $200F
立即 Operand #opernum e.g. ph1 #$0F
环境 Operand oaddr e.g. ph1 o$0005
隐含(堆栈)Operand e.g. and
伪指令定义
phx 把x个字节放在堆栈中(x=1,2,4,n)
比如,2000:12 34 56 78 90 ab cd ef
Stack: XX XX XX 00 00 00 00 00 00 00 00 00 00...
^ (S指针)
1.在完成 ph1 $2000后.. Stack: XX XX XX 12 00 00 00 00 00 00 00 00 00...
^ (S指针)
2.在完成 ph2 $2000后.. Stack: XX XX XX 12 34 00 00 00 00 00 00 00 00... (与上次不是连续的过程)
^ (S指针)
3.在完成 ph4 $2000后.. Stack: XX XX XX 12 34 56 78 00 00 00 00 00 00... (与上次不是连续的过程)
^ (S指针)
4.在完成 ph1 #$AB后.. Stack: XX XX XX AB 00 00 00 00 00 00 00 00 00... (与上次不是连续的过程)
^ (S指针)
5.在完成 ph2 #$ABCD后.. Stack: XX XX XX CD AB 00 00 00 00 00 00 00 00... (与上次不是连续的过程)
^ (S指针)
6.在完成 ph4 #$ABCDEF01后.. Stack: XX XX XX 01 EF CD AB 00 00 00 00 00 00... (与上次不是连续的过程)
^ (S指针)
7.在完成 phn #$12,#$23,#$00后.. Stack: XX XX XX 01 EF CD AB 00 00 00 00 00 00... (与上次不是连续的过程)
^ (S指针)
ret 返回上次调用点:这个不用解释吧?
goto 跳转:这个不用解释吧?
比如,goto $C10000, 就是跳转到.lav文件偏移0xC1的地方继续执行
call 调用子程序:这个不用解释吧?
比如,call $C10000, 就是调用.lav文件偏移0xC1的子程序
fsto 如果false goto(用法同goto)
add 加
比如,Stack: XX XX XX 12 00 00 00 23 00 00 00 00 00 ...
^(S指针)
1. 在完成add之后 Stack: XX XX XX 35 00 00 00 00 00 ...
.12+23=35 ^(S指针)
2. 在完成add #$0C01之后 Stack: XX XX XX 13 0C 00 00 00 00 00 ...
.C01+12=C13 ^(S指针)
mns 减(用法同加法)前4Bytes减后4Bytes, 或是前4Bytes减立即数
mul 乘(用法同加法)
div 整除(用法同加法)前4Bytes除以后4Bytes, 或是前4Bytes除以立即数
mod 求余(用法同加法)前4Bytes除以后4Bytes, 或是前4Bytes除以立即数
注意:以上资料均为sippey的成果
本文地址:http://com.8s8s.com/it/it25472.htm