duskos

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

commit d6fdd2977e6803dd7fd95d08d5837b1f0de76679
parent fcf5a2102457bf094bb79b73900f078027d23c81
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun,  2 Jul 2023 14:55:19 -0400

hal i386: support disp32 in +)

*still* no luck with that ar/ungz failure. Will I have to dig in puff.c source
to find that bug?

Diffstat:
Mfs/tests/hal.fs | 7+++++++
Mfs/xcomp/i386/kernel.fs | 24+++++++++++++++++-------
2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/fs/tests/hal.fs b/fs/tests/hal.fs @@ -294,4 +294,11 @@ code test32 ( a b -- a<<b ) PSP) <>) <<, drop, exit, $2a 4 test32 $2a0 #eq + +\ Test that +) can be more than a byte +create foo $100 allot0 42 , +code test33 ( a -- [a+$100] ) + W) $100 +) 8b) @, exit, + +foo test33 42 #eq testend diff --git a/fs/xcomp/i386/kernel.fs b/fs/xcomp/i386/kernel.fs @@ -156,15 +156,15 @@ xcode hbank' ( slot -- a ) \ preserves DX and DI ax lblhbank i) add, ret, -xcode hbank! ( n -- slot ) +xcode hbank! ( n -- slot ) \ Preserves DI dx ax mov, ax lblhbankidx m) mov, ax $f i) and, - di ax mov, + ax push, lblhbankidx m) inc, wcall, hbank' ax 0 d) dx mov, - ax di mov, + ax pop, ret, xcode hbank@ ( slot -- n ) @@ -173,7 +173,7 @@ xcode hbank@ ( slot -- n ) ret, \ Create a new "banked" operand from n -pc to lblnewbankedop ( n -- operand ) +pc to lblnewbankedop ( n -- operand ) \ preserves DI wcall, hbank! ax 20 i) shl, ax HALHASBANK i) or, @@ -194,6 +194,14 @@ xcode i) ( n -- operand ) ax HALIMM i) or, ret, +\ If operand's mod is 1 (disp8) and that n >= $100, upgrade mod to 2 (disp32) +pc to L2 ( operand -- operand ) \ di=n + di $ffffff00 i) test, forward8 jnz, ret, forward! + cl al mov, cl $c0 i) and, cl $40 i) cmp, forward8 jz, ret, forward! + \ upgrade needed + al $40 i) add, + ret, + \ When the operation already has a banked op, add to it instead of replacing it. pc to L1 ( operand n -- operand ) ax push, xdrop, ax push, @@ -201,18 +209,19 @@ pc to L1 ( operand n -- operand ) wcall, hbank' dx pop, ( operand ) cx pop, ( n ) ax 0 d) cx add, + di ax 0 d) mov, ax dx mov, - ret, + L2 absjmp, -\ TODO: allow disp32 offsets xcode +) ( operand n -- operand ) ax ax test, forward8 jnz, xdrop, ret, forward! si 0 d) HALHASBANK i) test, L1 abs>rel jnz, + di ax mov, \ save for L2 lblnewbankedop abscall, dx si 0 d) mov, xnip, ax dx or, ax $40 i) or, \ disp8 mode - ret, + L2 absjmp, xcode 8b) ( operand -- operand ) ax HAL8B ^ i) and, ret, @@ -291,6 +300,7 @@ pc to lblmodrmwr ( operand -- ) $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 + dl $80 i) cmp, L3 abs>rel jz, \ disp32 dl al mov, 0 dl reg!, dl $05 i) cmp, L3 abs>rel jz, \ m) means disp32 xdrop, ret,