duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit d36df5155713ba5da61455dc6193892c3838cc17
parent 3f6eb0aa81c8ff0e4418f602c7854cb68c2526c6
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sat,  1 Jul 2023 07:32:36 -0400

hal i386: fix &) bugs

Diffstat:
Mfs/tests/hal.fs | 14+++++++++++---
Mfs/xcomp/i386/kernel.fs | 11++++++++---
2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/fs/tests/hal.fs b/fs/tests/hal.fs @@ -46,7 +46,7 @@ test4 8 #eq code test5 ( -- n ) dup, -8 rs+, 42 i) @, RSP) !, - RSP) addr, + RSP) &) @, RSP) 4 +) !, \ reference to RS+0 in RS+4 \ Now, let's dereference RSP) 4 +) [@+], @@ -56,7 +56,7 @@ test5 42 #eq \ assign and dereference code test6 dup, -8 rs+, - RSP) addr, + RSP) &) @, RSP) 4 +) !, \ reference to RS+0 in RS+4 \ Now, let's assign-dereference 54 i) @, @@ -125,7 +125,7 @@ test12 85 #eq code test13 ( -- n ) dup, -8 rs+, 42 i) @, RSP) !, - RSP) addr, RSP) 4 +) !, + RSP) &) @, RSP) 4 +) !, 54 i) @, RSP) 4 +) [!+], RSP) @, @@ -231,4 +231,12 @@ code test24 ( -- a ) exit, 3 2 1 test24 @ 2 #eq 2drop drop + +\ &) and m) +code test25 ( -- 42 ) + dup, 42 m) &) @, + exit, + +current here over - spit +test25 42 #eq testend diff --git a/fs/xcomp/i386/kernel.fs b/fs/xcomp/i386/kernel.fs @@ -2,7 +2,7 @@ \ loading this binary as well as the Forth boot code following it in memory. \ We're in protected mode and all segments have been initialized. \ ESP=RSP ESI=PSP EBX=A EAX=W. They begin uninitialized. -\ HAL operand structure is the same as asm/i386 opmod structure. +\ HAL operand structure is similar to the asm/i386 opmod structure. \ Registers preserved/destroyed by words usually don't matter much: as an API, \ we must assume that all registers are destroyed. However, some words within \ the kernel refer to other words with register preservation assumptions. In @@ -228,8 +228,9 @@ pc to L2 ( operand -- ) \ disp8 \ Write modrm in AL, with disp8/disp32/SIB if appropriate. pc to lblmodrmwr ( operand -- ) al cwrite, - dx ax mov, dl $7 i) and, dl $4 i) cmp, - forward8 jnz, $24 i) cwrite, forward! \ sp? write SIB + dx ax mov, dl $7 i) and, dl $4 i) cmp, forward8 jnz, + dx ax mov, dl $c0 i) and, dl $c0 i) cmp, forward8 jz, + $24 i) cwrite, forward! forward! \ mod=3 and rm=SP? write SIB dl al mov, dl $c0 i) and, \ dl=mod dl $40 i) cmp, L2 abs>rel jz, \ disp8 al $05 i) cmp, L3 abs>rel jz, \ m) means disp32 @@ -240,6 +241,9 @@ pc to lblmodrmwr ( operand -- ) \ it. pc to lblderef ( operand -- operand ) ax HALDEREF i) test, forward8 jnz, ret, forward! + ax HALDEREF ^ i) and, + dx ax mov, dl $c7 i) and, dl $05 i) cmp, forward8 jnz, \ is m)? make it i) + al $38 i) and, ax HALIMM i) or, ret, forward! ax $c0 i) test, \ mod forward8 jnz, \ mod=0, set to mod=3 ax $c0 i) or, ret, forward! @@ -278,6 +282,7 @@ pc to L2 ( operand -- ) \ 16b or 8b, movzx $0f i) cwrite, ax $b600 i) or, L1 absjmp, xcode @, ( operand -- ) \ ax operand mov, + lblderef abscall, ax HALIMM i) test, L3 abs>rel jnz, ax HALINV i) test, forward8 jnz, \ inverted? no movzx! ax HAL16B i) test, L2 abs>rel jnz,