6126 - support 8-byte register names

Using these is quite unsafe. But what isn't, here?
This commit is contained in:
Kartik Agaram 2020-03-11 18:11:27 -07:00
parent 39eb1e4963
commit 15655a1246
7 changed files with 26 additions and 15 deletions

View File

@ -1,9 +1,9 @@
== data
Registers: # (table string int)
# a table is a stream
0x40/imm32/write
0x80/imm32/write
0/imm32/read
0x40/imm32/length
0x80/imm32/length
# data
"eax"/imm32 0/imm32
"ecx"/imm32 1/imm32
@ -13,3 +13,13 @@ Registers: # (table string int)
"ebp"/imm32 5/imm32
"esi"/imm32 6/imm32
"edi"/imm32 7/imm32
# for 8-byte registers
# we don't actually check if these are used when they should be; be careful
"al"/imm32 0/imm32
"cl"/imm32 1/imm32
"dl"/imm32 2/imm32
"bl"/imm32 3/imm32
"ah"/imm32 4/imm32
"ch"/imm32 5/imm32
"dh"/imm32 6/imm32
"bh"/imm32 7/imm32

Binary file not shown.

Binary file not shown.

BIN
apps/mu

Binary file not shown.

View File

@ -7523,7 +7523,7 @@ power-of-2?: # n: int -> result/eax: boolean
0b/and-> *(ebp+8) 0/r32/eax
# return (tmp2 == 0)
3d/compare-eax-and 0/imm32
0f 94/set-if-= %eax
0f 94/set-byte-if-= %al
81 4/subop/and %eax 0xff/imm32
$power-of-2?:end:
# . epilogue
@ -9714,7 +9714,7 @@ subx-type-equal?: # a: (handle tree type-id), b: (handle tree type-id) -> resul
(is-simple-mu-type? *(ebp+0xc) 0) # => eax
# return alit == blit
39/compare %eax 1/r32/ecx
0f 94/set-if-= %eax
0f 94/set-byte-if-= %al
81 4/subop/and %eax 0xff/imm32
$subx-type-equal?:end:
# . restore registers
@ -9735,7 +9735,7 @@ is-simple-mu-type?: # a: (handle tree type-id), n: type-id -> result/eax: boole
# return (a->value == n)
8b/-> *(ebp+8) 0/r32/eax
39/compare *eax 1/r32/ecx # Atom-type
0f 94/set-if-= %eax
0f 94/set-byte-if-= %al
81 4/subop/and %eax 0xff/imm32
$is-simple-mu-type?:end:
# . restore registers

Binary file not shown.

View File

@ -50,6 +50,7 @@ Opcodes currently supported by SubX:
5e: pop top of stack to ESI (pop)
5f: pop top of stack to EDI (pop)
68: push imm32 to stack (push)
69: multiply rm32 by imm32 and store result in r32
72: jump disp8 bytes away if lesser (unsigned), if CF is set (jcc/jb/jnae)
73: jump disp8 bytes away if greater or equal (unsigned), if CF is unset (jcc/jae/jnb)
74: jump disp8 bytes away if equal, if ZF is set (jcc/jz/je)
@ -99,16 +100,16 @@ Opcodes currently supported by SubX:
0f 8d: jump disp32 bytes away if greater or equal (signed), if SF == OF (jcc/jge/jnl)
0f 8e: jump disp32 bytes away if lesser or equal (signed), if ZF is set or SF != OF (jcc/jle/jng)
0f 8f: jump disp32 bytes away if greater (signed), if ZF is unset and SF == OF (jcc/jg/jnle)
0f 92: set rm32 to 1 if lesser (unsigned), if CF is set, 0 otherwise (setcc/setb/setnae)
0f 93: set rm32 to 1 if greater or equal (unsigned), if CF is unset, 0 otherwise (setcc/setae/setnb)
0f 94: set rm32 to 1 if equal, if ZF is set, 0 otherwise (setcc/setz/sete)
0f 95: set rm32 to 1 if not equal, if ZF is not set, 0 otherwise (setcc/setnz/setne)
0f 96: set rm32 to 1 if lesser or equal (unsigned), if ZF is set or CF is set, 0 otherwise (setcc/setbe/setna)
0f 97: set rm32 to 1 if greater (unsigned), if ZF is unset and CF is unset, 0 otherwise (setcc/seta/setnbe)
0f 9c: set rm32 to 1 if lesser (signed), if SF != OF, 0 otherwise (setcc/setl/setnge)
0f 9d: set rm32 to 1 if greater or equal (signed), if SF == OF, 0 otherwise (setcc/setge/setnl)
0f 9e: set rm32 to 1 if lesser or equal (signed), if ZF is set or SF != OF, 0 otherwise (setcc/setle/setng)
0f 9f: set rm32 to 1 if greater (signed), if ZF is unset and SF == OF, 0 otherwise (setcc/setg/setnle)
0f 92: set r8/m8-at-rm32 to 1 if lesser (unsigned), if CF is set, 0 otherwise (setcc/setb/setnae)
0f 93: set r8/m8-at-rm32 to 1 if greater or equal (unsigned), if CF is unset, 0 otherwise (setcc/setae/setnb)
0f 94: set r8/m8-at-rm32 to 1 if equal, if ZF is set, 0 otherwise (setcc/setz/sete)
0f 95: set r8/m8-at-rm32 to 1 if not equal, if ZF is not set, 0 otherwise (setcc/setnz/setne)
0f 96: set r8/m8-at-rm32 to 1 if lesser or equal (unsigned), if ZF is set or CF is set, 0 otherwise (setcc/setbe/setna)
0f 97: set r8/m8-at-rm32 to 1 if greater (unsigned), if ZF is unset and CF is unset, 0 otherwise (setcc/seta/setnbe)
0f 9c: set r8/m8-at-rm32 to 1 if lesser (signed), if SF != OF, 0 otherwise (setcc/setl/setnge)
0f 9d: set r8/m8-at-rm32 to 1 if greater or equal (signed), if SF == OF, 0 otherwise (setcc/setge/setnl)
0f 9e: set r8/m8-at-rm32 to 1 if lesser or equal (signed), if ZF is set or SF != OF, 0 otherwise (setcc/setle/setng)
0f 9f: set r8/m8-at-rm32 to 1 if greater (signed), if ZF is unset and SF == OF, 0 otherwise (setcc/setg/setnle)
0f af: multiply rm32 into r32 (imul)
Run `bootstrap help instructions` for details on words like 'r32' and 'disp8'.
For complete details on these instructions, consult the IA-32 manual (volume 2).