commit cb5475241063d4984a1a73a728aa4ec0143097aa
parent 3a312bd9d052ceeff9e70c95b096796b236821e4
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Wed, 29 Jun 2022 06:38:04 -0400
asm: add [i32] operand type
Diffstat:
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/fs/asm.fs b/fs/asm.fs
@@ -13,8 +13,8 @@
5 value BP
6 value SI
7 value DI
-8 value MEM
-9 value IMM
+5 value MEM
+8 value IMM
\ Variables
-1 value tgt \ target register. bit 31 is set if in indirect mode.
@@ -30,6 +30,7 @@
: tgt? tgt 0>= ;
: src? src 0>= ;
: disp? disp 0>= ;
+: disp32? src MEM = tgt MEM = or ;
: _id dup 0< if _err then $1f and ;
: tgtid tgt _id ;
: srcid src _id ;
@@ -54,9 +55,10 @@
: [edi] DI [r]! ;
: [ebp]+ ( disp -- ) BP [r]+8b! to disp ;
: i32 IMM $400 or to src ;
+: [i32] ( n -- ) MEM tgt-or-src! to disp ;
\ Writing the thing
-: disp, disp? if disp c, then ;
+: disp, disp? if disp disp32? if , else c, then then ;
: prefix, ( -- ) exit
tgt is16? if $66 c, then src isimm? not swap is16? and if $67 c, then ;
: op, ( op -- ) dup 8 rshift ?dup if c, then c, ;
diff --git a/fs/tests/asm.fs b/fs/tests/asm.fs
@@ -9,4 +9,13 @@ code foo
ret,
foo 42 #eq
+
+here 1234 , ( a )
+code foo
+ ebx [i32] mov,
+ ebp 4 i32 sub,
+ [ebp] ebx mov,
+ ret,
+
+foo 1234 #eq
testend