commit 6ec5c778d523144a4fbf6a2f6cb30c8930fc922b
parent ca7490b5087a738534ba6a5b46721b2900d0cc0a
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Thu, 25 May 2023 21:00:39 -0400
i386: remove spurious HAL number bank
It's not needed in Low HAL and is reimplemented in High HAL.
Diffstat:
2 files changed, 28 insertions(+), 34 deletions(-)
diff --git a/fs/doc/hal.txt b/fs/doc/hal.txt
@@ -44,6 +44,21 @@ few specialized A-related words.
The "High HAL" is implemented in the assemblers and complete the API. The API
of each half is described in the sections below.
+### Low HAL and number banks
+
+In addition to having access only to a subset of the High HAL, the Low HAL is
+also limited in the way it handles its operators.
+
+The High HAL, to be able to support arguments to +) and m) in the full 32-bit
+range while also keeping true to its promise that each operand only use one PS
+slot, uses what we call a "rolling number bank" where those parameters go and
+which allows up to 8 operators to "live" at once (that is, exist without being
+consumed by an operation). This makes the HAL very macro-able.
+
+The Low HAL has only a single slot in its number bank. This means that a +) or
+m) has to be consumed before another is created or else those parameters will be
+mixed up.
+
### Register allocation
The HAL has 4 virtual registers: W, A, PSP, RSP. Each architecture implementing
diff --git a/fs/xcomp/i386/kernel.fs b/fs/xcomp/i386/kernel.fs
@@ -28,9 +28,10 @@
\ Constants and labels
0 to realmode
: values ( n -- ) for 0 value next ;
-20 values lblmainalias lblbootptr lblnextword lblcurword lblnextmeta lblret
+21 values lblmainalias lblbootptr lblnextword lblcurword lblnextmeta lblret
lblsysdict lblparsec lblparseh lblparseud lblerrmsg lblhere lbl[rcnt]
lblwriterange lblfind lblcompiling lblidt lblmod lblrelwr lblcallwr
+ lblhbank
$8000 const HERESTART
$500 to binstart
$2000 const STACKSZ
@@ -107,32 +108,6 @@ xcode abort
0 jmp,
\ HAL operands
-pc to L1 HBANKCNT CELLSZ * allot
-pc to L2 0 ,
-xcode hbank' ( idx -- a )
- ax $0f i) and,
- ax 2 i) shl,
- ax L1 i) add,
- ret,
-
-xcode @) ( operand -- n )
- ax 20 i) shr,
- wcall, hbank'
- ax ax 0 d) mov,
- ret,
-
-xcode hbank! ( operand n -- operand )
- cx ax mov, \ cx=n
- ax L2 m) mov,
- L2 m) inc,
- bx ax mov, \ bx=idx
- wcall, hbank' \ ax=a
- ax 0 d) cx mov,
- xdrop, \ ax=operand
- bx 20 i) shl,
- ax bx or,
- ret,
-
$100 xconst W)
$107 xconst A)
$106 xconst PSP)
@@ -140,16 +115,18 @@ $104 xconst RSP)
$4 xconst Z)
$5 xconst NZ)
+pc to lblhbank 0 ,
xcode m) ( a -- operand )
- xgrow,
- si 0 d) $105 i) mov,
- wjmp, hbank!
+ lblhbank m) ax mov,
+ ax $105 i) mov,
+ ret,
pc to L1 xdrop, ret,
xcode +) ( operand n -- operand )
ax ax test, L1 abs>rel jz,
- si 0 d) $40 i) or, \ disp8 mode
- wjmp, hbank!
+ lblhbank m) ax mov, xdrop,
+ ax $40 i) or, \ disp8 mode
+ ret,
xcode 8b) ( operand -- operand )
ax $fffffeff i) and, ret,
@@ -222,10 +199,12 @@ xcode W<>A, ( n -- ) \ di ax xchg,
$97 i) cwrite, ret,
pc to L3 \ ax=opmod disp32
- wcall, @) ax dwrite,
+ ax lblhbank m) mov,
+ ax dwrite,
xdrop, ret,
pc to L2 \ ax=opmod disp8
- wcall, @) al cwrite,
+ ax lblhbank m) mov,
+ al cwrite,
xdrop, ret,
pc to L1 \ ax=opmod
ax $20000 i) test, forward8 jz, $66 i) cwrite, forward! \ 16b?