commit 3b916d7d2bd5bcf9e645f624cc167c63d66ecc6d
parent 740040668fe2c8da1e6fd1a14aecd56a1728d55c
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Thu, 29 Jun 2023 20:23:47 -0400
hal: re-add *,
i386 gets up to test5 in tests/hal and arm gets to test14!
Diffstat:
5 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/fs/asm/nbank.fs b/fs/asm/nbank.fs
@@ -8,8 +8,6 @@ create _bank $10 CELLSZ * allot
: newbankid ( n -- id ) to1+ _bankidx _bankidx $f and ;
: bank' ( id -- a ) CELLSZ * _bank + ;
: bank@ ( id -- n ) bank' @ ;
-\ This alias is to give the opportunity to HALs to update their kernel-level
-\ number bank (single) at the same time as the High HAL number bank. This word
-\ is realiased in High HAL units.
alias drop oldbank! ( n -- )
+S" HBANK" sysdict find [if] : oldbank! HBANK ! ; [then]
: bank! ( n -- id ) dup oldbank! newbankid tuck bank' ! ;
diff --git a/fs/xcomp/arm/rpi/kernel.fs b/fs/xcomp/arm/rpi/kernel.fs
@@ -745,12 +745,25 @@ xcode @!, ( operand -- )
( pc ) r0 pc@>reg,
lblopwr abs>rel b) ,)
+\ Handle "mul" by moving Rn to Rm, setting Rn to zero.
+pc to L1 ( operand -- ) \ r0=instr
+ and) r1 rd) rTOP rn) $f000 imm) ,) \ Rn
+ bic) rTOP rdn) $f000 imm) ,)
+ orr) rTOP rdn) r1 rm) 4 lsr) ,)
+ lblopwr abs>rel b) ,)
+
\ Proxy lblopwr and add a special rule: if opecode is one of the "comparison"
-\ opcodes, forcefully set Rd to 0 before writing it off.
+\ opcodes, forcefully set Rd to 0 before writing it off. Also check for "mul".
pc to L4 ( operand -- ) \ r0=instr
and) r1 rd) r0 rn) $01900000 imm) ,)
cmp) r1 rn) $01100000 imm) ,)
setrd0) z) rTOP rdn) ,)
+ and) z) r1 rd) r0 rn) $01900000 imm) ,)
+ and) r1 rd) r0 rn) $0ff00000 imm) ,)
+ and) r2 rd) r0 rn) $000000f0 imm) ,)
+ orr) r1 rdn) r2 rm) ,)
+ cmp) r1 rn) $00000090 imm) ,)
+ L1 abs>rel b) z) ,)
lblopwr abs>rel b) ,)
\ Write arithmetic operation with an immediate src
@@ -822,6 +835,9 @@ xcode ^, ( operand -- )
xcode compare, ( operand -- )
mov) r0 rd) $01500000 imm) ,) ( cmp ) L1 abs>rel b) ,)
+xcode *, ( operand -- )
+ mov) r0 rd) $00000090 imm) ,) ( mul ) L1 abs>rel b) ,)
+
xcode +n, ( n operand -- )
lblimmwr abscall,
setrd0) rTOP rdn) ,)
@@ -988,6 +1004,7 @@ pc
mov) rTOP rd) r1 rm) ,) \ quotient
ret,
+\ Speed-critical words
xcode move ( src dst u -- )
r2 ppop, r0 ppop, \ r0=src r2=dst
mov) r1 rd) rTOP rm) ,) xdrop, \ r1=u
diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs
@@ -104,6 +104,7 @@ Z) _ = NZ) _ <> >) _ < <) _ > >=) _ <= <=) _ >=
\ Arithmetic
: 0>= $80000000 < ;
: 0< 0>= not ;
+code * PSP) *, nip, exit,
: / /mod nip ;
: mod /mod drop ;
: ?swap ( n n -- l h ) 2dup > if swap then ;
diff --git a/fs/xcomp/i386/kernel.fs b/fs/xcomp/i386/kernel.fs
@@ -286,6 +286,9 @@ xcode +n, ( n operand -- ) \ operand n i) add,
ax $8000 i) or, L1 abscall, ( n -- )
ax dwrite, xdrop, ret,
+xcode *, ( operand -- ) \ TODO: support A>) and i)
+ ax $f720 i) or, L1 absjmp,
+
\ Write: di 32b) operand mov, operand 32b) 1/2/4 i) add,
pc to L2 ( operand -- operand-with-di-src )
xdup,
diff --git a/posix/vm.c b/posix/vm.c
@@ -1016,7 +1016,6 @@ static void buildsysdict() {
entry("branch!"); storewr(); retwr();
entry("yield"); compileop(0x07); retwr(); makeimm();
entry(";"); compileop(0x02); cwrite(0x3d); retwr(); makeimm();
- entry("*"); binopwr(0x02, OPPSP); nipwr(); retwr();
entry("lshift"); wopwr(0x12 /* @! */, OPPSP); binopwr(0x05, OPPSP); nipwr(); retwr();
entry("rshift"); wopwr(0x12 /* @! */, OPPSP); binopwr(0x06, OPPSP); nipwr(); retwr();
entry("<<"); litwr(1); callwr(find("lshift")); retwr();