commit e10c4e928c341578e2db7420f0fc40e13373e957
parent 5a048ae822205dbd4cea44613dacd14bf1a461ab
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Thu, 16 Mar 2023 21:11:51 -0400
hal: Add "A=0>Z," and remove ">branchC,"
>branchC, is too inefficient on i386. It was a bad idea.
Diffstat:
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs
@@ -70,13 +70,13 @@ code 1- -1 W+n, exit,
: , HERE @!+ ; :16b HERE 16b @!+ ; :8b HERE 8b @!+ ; : c, 8b , ;
code execute W>A, drop, branchA,
-code not =0>Z, Z>W, exit,
-code bool =0>Z, Z>W, 1 xorn, exit,
+code not W=0>Z, Z>W, exit,
+code bool W=0>Z, Z>W, 1 xorn, exit,
: litn dup, LIT>W, ;
-: if 0 =0>Z, Z) >branchC, ; immediate
+: if 0 W>A, drop, A=0>Z, Z) branchC, ; immediate
: ahead 0 branch, ; immediate
: then HERE @ swap branch! ; immediate
-code ?dup =0>Z, 0 Z) branchC, dup, then exit,
+code ?dup W=0>Z, 0 Z) branchC, dup, then exit,
: ' word sysdict @ find dup not if (wnf) then ;
: ['] ' litn ; immediate
: compile ' litn ['] execute, execute, ; immediate
@@ -85,7 +85,7 @@ code ?dup =0>Z, 0 Z) branchC, dup, then exit,
: else [compile] ahead HERE @ rot branch! ; immediate
: begin HERE @ ; immediate
: again branch, drop ; immediate
-: until =0>Z, Z) >branchC, drop ; immediate
+: until W>A, drop, A=0>Z, Z) branchC, drop ; immediate
: = - not ;
: \ begin in< $0a = until ; immediate
\ hello, this is a comment!
@@ -268,7 +268,7 @@ code (s) r@ W>A, W) 8b) @, 1 W+n, RSP) +, rdrop W<>A, branchA,
: word" [compile] S" NEXTWORD litn compile ! ; immediate
code []= ( a1 a2 u -- f )
- =0>Z, 0 Z) branchC, PSP) @!, W>A, begin \ P+4=a1 P+0=u A=a2
+ W=0>Z, 0 Z) branchC, PSP) @!, W>A, begin \ P+4=a1 P+0=u A=a2
PSP) 4 +) 8b) [@], A) 8b) cmp, 0 Z) branchC,
8 ps+, 0 LIT>W, exit, then
1 A+n, 1 PSP) 4 +) [+n], -1 PSP) [+n], NZ) branchC, drop then
@@ -282,7 +282,7 @@ $01 const EMETA_DOCLINE \ a doc strings that ends with LF
: \\ nextmeta lladd drop EMETA_DOCLINE , begin in< dup c, LF = until ;
code move ( src dst u -- )
- =0>Z, 0 Z) branchC, W>A, begin \ A=u
+ W=0>Z, 0 Z) branchC, W>A, begin \ A=u
PSP) 4 +) 8b) [@], PSP) 8b) [!],
1 PSP) 4 +) [+n], 1 PSP) [+n],
-1 A+n, NZ) branchC, drop then
diff --git a/posix/vm.c b/posix/vm.c
@@ -202,7 +202,6 @@ static int checkcond(byte cond) {
}
}
static void BRC() { byte cond = gpcb(); dword a = gpc(); if (checkcond(cond)) vm.PC = a; }
-static void BRCDROP() { BRC(); ppop(); }
static void YIELD() { dword pc = vm.PC; vm.PC = rpop(); rpush(pc); }
static void PSADD() { vm.PSP += gpc(); } // 0x08
@@ -484,8 +483,9 @@ static void SHRN() { vm.W >>= gpcb(); }
static void ANDN() { vm.W &= gpc(); }
static void ORN() { vm.W |= gpc(); }
static void XORN() { vm.W ^= gpc(); }
-static void CHECKZ() { vm.Z = !vm.W; }
+static void WCHECKZ() { vm.Z = !vm.W; }
static void STOREZ() { vm.W = vm.Z; }
+static void ACHECKZ() { vm.Z = !vm.A; }
/* Filesystem
@@ -767,7 +767,7 @@ static void DRVWR() {
#define OPCNT 0x78
static void (*ops[OPCNT])() = {
- BR, CALL, RET, BRWR, BRA, BRC, BRCDROP, YIELD,
+ BR, CALL, RET, BRWR, BRA, BRC, NULL, YIELD,
PSADD, RSADD, WLIT, ALIT, WADDN, AADDN, W2A, WSWAPA,
WFETCH, WSTORE, WSWAP, MADDN, WCMP, WIFETCH, WISTORE, WADD,
WFETCH16, WSTORE16, WSWAP16, MADDN16, WCMP16, WIFETCH16, WISTORE16, WADD16,
@@ -779,7 +779,7 @@ static void (*ops[OPCNT])() = {
SUB, MUL, DIVMOD, LSHIFT, RSHIFT, LT, NULL, NULL,
AND, OR, XOR, NULL, NULL, NULL, NULL, NULL,
BYE, BYEFAIL, QUIT, ABORT_, DBG, USLEEP, NULL, NULL,
- SHLN, SHRN, ANDN, ORN, XORN, CHECKZ, STOREZ, NULL,
+ SHLN, SHRN, ANDN, ORN, XORN, WCHECKZ, STOREZ, ACHECKZ,
FCHILD, FOPEN, FREADBUF, FCLOSE, FINFO, FITER, NULL, FSEEK,
MOUNTDRV, UNMOUNTDRV, DRVRD, DRVWR, NULL, NULL, NULL, NULL,
};
@@ -841,7 +841,6 @@ static void buildsysdict() {
sysconst("MOD", MOD);
sysconst("CALLSZ", 5);
sysconst("BRSZ", 5);
- sysconst("?BRSZ", 5);
sysconst("PSTOP", PSTOP);
sysconst("RSTOP", RSTOP);
sysconst("curword", CURWORD);
@@ -878,14 +877,14 @@ static void buildsysdict() {
entry("andn,"); compileop(0x62); writewr(); retwr();
entry("orn,"); compileop(0x63); writewr(); retwr();
entry("xorn,"); compileop(0x64); writewr(); retwr();
- entry("=0>Z,"); compileop(0x65); retwr();
+ entry("W=0>Z,"); compileop(0x65); retwr();
entry("Z>W,"); compileop(0x66); retwr();
+ entry("A=0>Z,"); compileop(0x67); retwr();
entry("exit,"); compileop(0x02); retwr();
entry("execute,"); compileop(0x01); writewr(); retwr();
entry("branchA,"); compileop(0x04); retwr();
entry("branch,"); litwr(0x00); cwritewr(); cwrite(0x03); retwr();
entry("branchC,"); litwr(0x05); cwritewr(); cwritewr(); cwrite(0x03); retwr();
- entry(">branchC,"); litwr(0x06); cwritewr(); cwritewr(); cwrite(0x03); retwr();
entry("branch!"); storewr(); retwr();
entry("yield"); compileop(0x07); retwr(); makeimm();
entry(";"); compileop(0x02); cwrite(0x3d); retwr(); makeimm();