commit 3b8fc71428286e9331f272246790cf71abd1616c
parent 39c4cc52adcc529e7754f816eded31ba415b2321
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sat, 1 Jul 2023 08:13:40 -0400
i386: move immediate flag from b15 to b18 in HAL and asm operands
This flag was the only flag in the lower 16bit of the oeprand that couldn't
safely be written as native i386. Therefore, it sometimes conflicted with opcode
being written in the operand.
The original idea is that *yes*, b15 indicates an immediate operation, in the
sense that all imm-based operations have this flag set. However, the reverse
isn't true: it's not because this flag is set that the operation is immediate.
Example: MUL/DIV
Therefore, there was no gain in having this flag there, only pain.
Diffstat:
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/fs/asm/i386.fs b/fs/asm/i386.fs
@@ -7,11 +7,11 @@
\ b5:3 zeroes except when register is a "special" one for mov,
\ b7:6 mod ( displacement in bank if present )
\ b8 0=8b 1=32/16b
-\ b14:9 zeroes
-\ b15 immediate? ( value in bank )
+\ b15:9 zeroes
\ b16 opcode is 2 bytes (has $0f extension byte)
\ b17 16b?
-\ b19:18 zeroes
+\ b18 immediate? ( value in bank )
+\ b19 zero
\ b23:20 Number bank index
\ b31:24 SIB
\ When we refer to "opmod" below, it's this structure
@@ -26,7 +26,7 @@
: bankid@ 20 rshift $f and ;
: newbankedop ( n -- opmod ) bank! 20 lshift ;
: sib@ 24 rshift ;
-: imm? $8000 and bool ;
+: imm? $40000 and bool ;
: 8b? bi $100 and not | $ff00 and $8300 = or ;
: 16b? $20000 and bool ;
: special? $38 and bool ;
@@ -68,7 +68,7 @@ $100 _ ax $101 _ cx $102 _ dx $103 _ bx $104 _ sp $105 _ bp $106 _ si $107 _ di
0 _ bx+si) 1 _ bx+di) 2 _ bp+si) 3 _ bp+di) 4 _ si+) 5 _ di+) 6 _ _bp+) 7 _ bx+)
: bp+) ?dup if _bp+) else 1 _bp+) 0 over bankid@ bank' ! then ;
-: i) newbankedop $8000 or ;
+: i) newbankedop $40000 or ;
: m) newbankedop memmodrm $100 or or ;
: d)
notreal# _d)
diff --git a/fs/xcomp/i386/kernel.fs b/fs/xcomp/i386/kernel.fs
@@ -13,11 +13,10 @@
\ b5:3 dst regid
\ b7:6 mod ( displacement in bank if present )
\ b8 0=8b 1=32/16b
-\ b14:9 zeroes
-\ b15 immediate? ( value in bank )
+\ b15:9 zeroes
\ b16 "&)" flag
\ b17 16b?
-\ b18 zero
+\ b18 immediate? ( value in bank )
\ b19 "<>)" flag
\ b23:20 Number bank index
\ b31:24 zeroes
@@ -58,7 +57,7 @@ $80000 const PSTOP
PSTOP STACKSZ - const HEREMAX
$100 const HAL8B
$20000 const HAL16B
-$8000 const HALIMM
+$40000 const HALIMM
$10000 const HALDEREF
$80000 const HALINV