commit 58df023daf6219f2dc750cd44f199a77169c7fd9
parent 64208509a28101653791de438b1870b4a809a443
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Thu, 18 May 2023 21:02:27 -0400
hal i386: add inc/dec special cases to W+n, A+n, and [+n],
Diffstat:
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/fs/asm/i386.fs b/fs/asm/i386.fs
@@ -297,7 +297,11 @@ op &, and, op |, or, op ^, xor,
dup imm? not if cx swap mov, cl then | execute ;
op <<, shl, op >>, shr,
-: [+n], ( n halop -- ) halop>dstsrc nip swap i) add, ;
+: [+n], ( n halop -- )
+ halop>dstsrc nip swap case ( op )
+ 1 of = inc, endof
+ -1 of = dec, endof
+ r@ i) add, endcase ;
: _ ( halop -- dst src )
dup 16b? >r dup 8b? >r 32b)
halop>dstsrc bx swap mov, ( dst )
diff --git a/fs/xcomp/i386/kernel.fs b/fs/xcomp/i386/kernel.fs
@@ -205,10 +205,14 @@ xcode LIT>W, ( n -- ) \ ax XX i) mov,
xcode LIT>A, ( n -- ) \ di XX i) mov,
$bf i) cwrite, L1 absjmp,
-xcode W+n, ( n -- ) \ ax XX i) add,
+xcode W+n, ( n -- ) \ ax XX i) add, OR ax inc,/dec,
+ ax 1 i) cmp, forward8 jnz, $40 i) cwrite, xdrop, ret, forward!
+ ax -1 i) cmp, forward8 jnz, $48 i) cwrite, xdrop, ret, forward!
$05 i) cwrite, L1 absjmp,
-xcode A+n, ( n -- ) \ di XX i) add,
+xcode A+n, ( n -- ) \ di XX i) add, OR di inc,/dec,
+ ax 1 i) cmp, forward8 jnz, $47 i) cwrite, xdrop, ret, forward!
+ ax -1 i) cmp, forward8 jnz, $4f i) cwrite, xdrop, ret, forward!
$c781 i) wwrite, L1 absjmp,
xcode W>A, ( n -- ) \ di ax mov,
@@ -271,7 +275,9 @@ xcode [!], ( operand -- )
al $03 i) mov, \ keep size, but modrm is for bx 0 d) ax mov,
L1 absjmp,
-xcode [+n], ( n operand -- ) \ operand n i) add,
+xcode [+n], ( n operand -- ) \ operand n i) add, OR operand inc,/dec,
+ si 0 d) 1 i) cmp, forward8 jnz, xnip, ax $fe00 i) or, L1 absjmp, forward!
+ si 0 d) -1 i) cmp, forward8 jnz, xnip, ax $fe08 i) or, L1 absjmp, forward!
ax $8000 i) or, L1 abscall, ( n -- )
ax dwrite, xdrop, ret,