commit 892d307d5fbabfac4c45b13f0cdcff7481318a53
parent 8f77d1ddd2acef25bef8b533a15e48be622e5645
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Tue, 10 Jan 2023 16:11:41 -0500
Move "rtype" outside of kernel
Diffstat:
3 files changed, 17 insertions(+), 44 deletions(-)
diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs
@@ -133,8 +133,9 @@ alias noop idle
\ Emitting
$20 const SPC $0d const CR $0a const LF $08 const BS
+alias drop emit
: nl> CR emit LF emit ; : spc> SPC emit ;
-\ emit all chars of "str"
+: rtype ( a u ) >r begin c@+ emit next drop ;
: stype ( str -- ) c@+ rtype ;
: S" ( comp: -- ) ( not-comp: -- str )
compiling if compile (s) else here then
diff --git a/fs/xcomp/i386/kernel.fs b/fs/xcomp/i386/kernel.fs
@@ -15,8 +15,8 @@
\ Constants and labels
0 to realmode
: values ( n -- ) >r begin 0 value next ;
-21 values lblmainalias lblbootptr lblnextword lblcurword lblnextmeta lblret
- lblsysdict lblparsec lblparseh lblparseud lblerrmsg lblrtype lblhere
+20 values lblmainalias lblbootptr lblnextword lblcurword lblnextmeta lblret
+ lblsysdict lblparsec lblparseh lblparseud lblerrmsg lblhere
lbl[rcnt] lblmovewrite lblwrite lblcwrite lblfind lblcompiling lblidt
lblwoff
$8000 const HERESTART
@@ -128,10 +128,6 @@ xcode execute
AX pspop,
ax jmp,
-xcode drop \ we could remove it, but EMIT defaults to it...
- ps-,
- ret,
-
xcode dup ( a -- a a )
ax [ebp] mov,
AX pspush,
@@ -630,30 +626,16 @@ xcode ?b
xwordlbl 16b abs>rel jz,
ret,
-xcode emit xwordlbl drop abs>rel jmp,
-
-xcode rtype ( a u -- )
- CX SI pspop2,
-pc to lblrtype
- cx cx test,
- lblret abs>rel jz,
- al [esi] movclr,
- AX pspush,
- si push, cx push,
- wcall, emit
- cx pop, si pop,
- si inc,
- lblrtype abs>rel loop,
- ret,
+xcode rtype xwordlbl (abort) abs>rel jmp,
\ During early boot, it's better to halt the machine than to go back to the
\ mainloop because the mainloop likely sends us to an infinite error loop
\ through boot<.
pc ," boot failure"
xcode abort
- cx 12 i) mov,
- si ( msg ) i) mov,
- lblrtype abs>rel call,
+ ( pc ) pspushN,
+ 12 pspushN,
+ wcall, rtype
0 jmp,
0 align4 pc to lblbootptr 0 ,
@@ -739,7 +721,9 @@ xcode word
cx 13 i) mov,
si ( pc ) i) mov,
pc to lblerrmsg \ exc=sl esi=sa
- lblrtype abs>rel call,
+ SI pspush,
+ CX pspush,
+ wcall, rtype
xwordlbl abort abs>rel jmp,
xcode find ( str 'dict -- word-or-0 )
@@ -776,9 +760,10 @@ L1 forward! ( skip1 )
pc ," word not found"
xcode (wnf)
- si lblcurword 1+ i) mov,
+ lblcurword 1+ pspushN,
cl lblcurword m) movclr,
- lblrtype abs>rel call,
+ CX pspush,
+ wcall, rtype
cx 15 i) mov,
si ( pc ) i) mov,
lblerrmsg abs>rel jmp,
diff --git a/posix/vm.c b/posix/vm.c
@@ -54,7 +54,6 @@ static FILE *fp;
// Addresses of sysaliases
static dword abortaddr;
-static dword emitaddr;
static dword inrdaddr;
static dword mainaddr;
@@ -604,17 +603,6 @@ static void MOVEWR() { // op: 4d
MOVE();
}
-static void RTYPE() { // op: 4e
- dword u = ppop();
- dword a = ppop();
- if (memchk(a+u)) {
- for (int i=0; i<u; i++) {
- ppush(vm.mem[a+i]);
- callword(emitaddr);
- }
- }
-}
-
static void WNF() { // op: 4f
write(STDOUT_FILENO, &vm.mem[CURWORD+1], vm.mem[CURWORD]);
write(STDOUT_FILENO, " word not found", 15);
@@ -1064,7 +1052,7 @@ static void (*ops[OPCNT])() = {
WRITE, SRD, SWR, WOFF, SETBW, SET16B, SET8B, SETNB,
INC, DEC, ADD, SUB, MUL, DIVMOD, AND, ALIGN4,
OR, XOR, BOOL, NOT, LT, SHLC, SHRC, LSHIFT,
- RSHIFT, LITN, EXECUTEWR, EXITWR, MOVE, MOVEWR, RTYPE, WNF,
+ RSHIFT, LITN, EXECUTEWR, EXITWR, MOVE, MOVEWR, NULL, WNF,
STACKCHK, MAYBEWORD, WORD, PARSE, REQ, FIND, APOS, COMPILING,
ALIASWR, STARTCOMP, STOPCOMP, COMPWORD, RUNWORD, NULL, NULL, NULL,
FCHILD, FOPEN, FREADBUF, FCLOSE, FINFO, FITER, FSEEK, NULL,
@@ -1080,7 +1068,7 @@ static char *opnames[OPCNT] = {
",", "\"<", ",\"", "(woff)", NULL, "16b", "8b", "?b",
"1+", "1-", "+", "-", "*", "/mod", "and", "align4",
"or", "xor", "bool", "not", "<", "<<c", ">>c", "lshift",
- "rshift", "litn", "execute,", "exit,", "move", "move,", "rtype", "(wnf)",
+ "rshift", "litn", "execute,", "exit,", "move", "move,", NULL, "(wnf)",
"stack?", "maybeword", "word", "parse", "[]=", "find", "'", "compiling",
"alias,", "]", "[", "compword", "runword", NULL, NULL, NULL,
"_fchild", "_fopen", "_freadbuf", "_fclose", "_finfo", "_fiter", "_fseek", NULL,
@@ -1168,10 +1156,9 @@ static void buildsysdict() {
makeimm("8b");
sysalias("abort", "byefail");
abortaddr = find("abort");
- sysalias("emit", "(emit)");
- emitaddr = find("emit");
sysalias("in<", "boot<");
inrdaddr = find("in<");
+ sysalias("rtype", "byefail");
sysconst("HERE", HERE);
sysconst("NEXTWORD", NEXTWORD);
sysconst("HEREMAX", HEREMAX);