ref: 233d3610369f2e69bedd84558250271c0acae4de
parent: 2a12d6d0d04bfaea941cb6c37c02c513bcd3ece8
author: 9ferno <[email protected]>
date: Tue Nov 23 09:42:40 EST 2021
working c calls
--- a/os/pc64/bindings.s
+++ b/os/pc64/bindings.s
@@ -5,6 +5,32 @@
not maintaining the values of the temporary registers or EFLAGS
*/
+#define STORE(x,y) \
+ MOVQ $y, CX; \
+ ADDQ UP, CX; \
+ MOVQ x, 0(CX)
+
+#define STOREFORTH \
+ STORE(TOP,FORTHTOP);\
+ STORE(PSP,FORTHPSP);\
+ STORE(RSP,FORTHRSP);\
+ STORE(IP,FORTHIP);\
+ STORE(W,FORTHW);\
+ STORE(UP,FORTHUP);
+
+#define RESTORE(x,y) \
+ MOVQ $x, CX; \
+ ADDQ UP, CX; \
+ MOVQ 0(CX), y;
+
+#define RESTOREFORTH \
+ RESTORE(FORTHTOP,TOP);\
+ RESTORE(FORTHPSP,PSP);\
+ RESTORE(FORTHRSP,RSP);\
+ RESTORE(FORTHIP,IP);\
+ RESTORE(FORTHW,W);\
+ RESTORE(FORTHUP,UP);
+
/*
using
( 2nd_parameter 1st_parameter -- ) mode fd open
@@ -14,9 +40,10 @@
might revisit this later after a trial
there is no forth word for this. It is call'able by the bindings subroutines
+cannot get this to work and I cannot decipher it with all the psuedo register nonsense
*/
-TEXT ff_to_c(SB), 1, $-4 /* ( argn .. arg2 arg1 nargs -- ) (G move args to C stack) */
- POPQ SI /* get the return PC from the stack */
+TEXT ff_to_c(SB), $0 /* ( argn .. arg2 arg1 nargs -- ) (G move args to C stack) */
+ POPQ SI /* get my return PC from the stack */
MOVQ TOP, CX /* check nargs */
POP(TOP)
TESTQ $0, CX
@@ -27,62 +54,70 @@
POP(TOP)
LOOP .ff_to_c_again
.ff_to_c_done:
- PUSH(TOP)
- PUSH(RSP)
- PUSH(IP)
- PUSH(W)
- MOVQ PSP, forthsp(SB);
+ STOREFORTH
JMP* SI /* go back to the caller */
-TEXT c_to_ff_0(SB), 1, $-4 /* no returned argument */
- MOVQ forthsp(SB), PSP
- POP(W)
- POP(IP)
- POP(RSP)
- POP(TOP)
- RET
-TEXT c_to_ff_1(SB), 1, $-4 /* there is a returned argument */
- CALL c_to_ff_0(SB)
- PUSH(TOP)
- MOVQ AX, TOP /* C puts the return value in AX */
- RET
+#define C_TO_F_0 \
+ RESTOREFORTH;
+#define C_TO_F_1 /* there is a returned argument */\
+ C_TO_F_0; \
+ PUSH(TOP); \
+ MOVQ AX, TOP; /* C puts the return value in AX */\
+
+#define F_TO_C_3 \
+ MOVQ TOP, RARG;\
+ POP(TOP);\
+ MOVQ TOP, 8(SP);\
+ POP(TOP);\
+ MOVQ TOP, 16(SP);\
+ POP(TOP);\
+ STOREFORTH;
+
+#define F_TO_C_2 \
+ MOVQ TOP, RARG;\
+ POP(TOP);\
+ MOVQ TOP, 8(SP);\
+ POP(TOP);\
+ STOREFORTH;
+
+#define F_TO_C_1 \
+ MOVQ TOP, RARG;\
+ POP(TOP);\
+ STOREFORTH;
+
TEXT fthopen(SB), 1, $-4 /* ( mode cstr -- fd ) */
- PUSH(TOP)
- MOVQ $2, TOP
- CALL ff_to_c(SB)
+ F_TO_C_2
CALL kopen(SB)
- CALL c_to_ff_1(SB)
+ C_TO_F_1
NEXT
TEXT fthclose(SB), 1, $-4 /* ( fd -- n ) */
- PUSH(TOP)
- MOVQ $1, TOP
- CALL ff_to_c(SB)
+ F_TO_C_1
CALL kclose(SB)
- CALL c_to_ff_1(SB)
+ C_TO_F_1
NEXT
TEXT fthread(SB), 1, $-4 /* ( n a fd -- n2 ) */
- PUSH(TOP)
- MOVQ $3, TOP
- CALL ff_to_c(SB)
+ MOVQ (PSP), CX /* address = start of heap + address */
+ ADDQ UP, CX
+ MOVQ CX, (PSP)
+ F_TO_C_3
CALL kread(SB)
- CALL c_to_ff_1(SB)
+ C_TO_F_1
NEXT
TEXT fthwrite(SB), 1, $-4 /* ( n a fd -- n2 ) */
- PUSH(TOP)
- MOVQ $3, TOP
- CALL ff_to_c(SB)
+ MOVQ (PSP), CX /* address = start of heap + address */
+ ADDQ UP, CX
+ MOVQ CX, (PSP)
+ F_TO_C_3
CALL kwrite(SB)
- CALL c_to_ff_1(SB)
+ C_TO_F_1
NEXT
TEXT fthseek(SB), 1, $-4 /* ( type pos fd -- n ) */
- PUSH(TOP)
- MOVQ $3, TOP
- CALL ff_to_c(SB)
+ F_TO_C_3
CALL kseek(SB)
- CALL c_to_ff_1(SB)
+ C_TO_F_1
NEXT
--- a/os/pc64/forth.s
+++ b/os/pc64/forth.s
@@ -44,7 +44,7 @@
UP: variables
heap start, heapstart, also in UP
heap size, heapsize
- forth stack pointer, forthsp
+ forth stack pointer, forthpsp
dictionary pointer, Dp
latest dictionary entry, Dtop
need this as the system definitions and
@@ -86,33 +86,17 @@
*/
#define HEAPSTART (0ull)
#define HEAPEND (HEAPSTART+(BY2WD*1))
-#define FORTHSP (HEAPSTART+(BY2WD*2))
-#define DP (HEAPSTART+(BY2WD*3)) /* cannot use H as it is nil in inferno
- next available cell for the dictionary */
-#define DTOP (HEAPSTART+(BY2WD*4))
- /* variables used by the core words */
-#define TOIN (HEAPSTART+(BY2WD*5))
-#define TOLIMIT (HEAPSTART+(BY2WD*6))
-#define FINDADR (HEAPSTART+(BY2WD*7))
-#define BLK (HEAPSTART+(BY2WD*8))
-#define ARGS (HEAPSTART+(BY2WD*9))
-#define IOBUF (HEAPSTART+(BY2WD*10))
-#define SEARCHLEN (HEAPSTART+(BY2WD*11))
-#define BASE (HEAPSTART+(BY2WD*12))
-#define TONUM (HEAPSTART+(BY2WD*13))
-#define STATE (HEAPSTART+(BY2WD*14))
-#define ABORTVEC (HEAPSTART+(BY2WD*15))
-#define SOURCEBUF (HEAPSTART+(BY2WD*16))
-#define WORDBUF (HEAPSTART+(BY2WD*17))
-#define INFD (HEAPSTART+(BY2WD*18))
-#define OUTFD (HEAPSTART+(BY2WD*19))
-#define ERRFD (HEAPSTART+(BY2WD*20))
-#define EOF (HEAPSTART+(BY2WD*21))
+#define FORTHTOP (HEAPSTART+(BY2WD*2))
+#define FORTHPSP (HEAPSTART+(BY2WD*3))
+#define FORTHRSP (HEAPSTART+(BY2WD*4))
+#define FORTHIP (HEAPSTART+(BY2WD*5))
+#define FORTHW (HEAPSTART+(BY2WD*6))
+#define FORTHUP (HEAPSTART+(BY2WD*7))
+#define ARGS (HEAPSTART+(BY2WD*3))
+#define ERRSTR (HEAPSTART+(BY2WD*16))
+#define WORDB (HEAPSTART+(BY2WD*144)) /* word buffer */
-#define ERRSTR (HEAPSTART+(BY2WD*32))
-#define WORDB (HEAPSTART+(BY2WD*160)) /* word buffer */
-
-#define DICTIONARY (HEAPSTART+2048) /* dictionary */
+#define DICTIONARY (HEAPSTART+(BY2WD*256)) /* dictionary */
#define DICTIONARY_END (HEAPSTART+(6*BY2PG))
#define PSTACK (HEAPSTART+(6*BY2PG))
#define PSTACK_END (HEAPSTART+(7*BY2PG))
@@ -123,7 +107,6 @@
#define HEAPSIZE FORTHEND
#define LAST $centry_c_boot(SB) /* last defined word, should generate this */
-
/* putting this above the asm code as the v_dp define is needed by _main */
/* m_ for primitive/macro word cfa
mc_ for primtive/macro word constants
@@ -156,8 +139,10 @@
MOVQ UP, TOP
ADDQ $DICTIONARY, TOP
- MOVQ TOP, 24(UP) /* dictionary pointer */
- MOVQ $centry_c_boot(SB), 24(UP) /* Latest dictionary entry address */
+ MOVQ $mventry_Dp(SB), CX
+ MOVQ TOP, 24(CX) /* dictionary pointer */
+ MOVQ $mventry_Dtop(SB), CX
+ MOVQ $centry_c_boot(SB), 24(CX) /* Latest dictionary entry address */
/* execute boot */
MOVQ $centry_c_boot(SB), IP
@@ -176,9 +161,9 @@
Assume IP = 8
*/
#define NEXT MOVQ (IP), W; /* W = 40, contents of address in IP, some word's code field address */ \
- MOVQ (W), TOP; /* TOP = docol, Get the address in the address in IP = code field address */ \
+ MOVQ (W), CX; /* TOP = docol, Get the address in the address in IP = code field address */ \
ADDQ $8, IP; /* move IP further, IP = 16 */ \
- JMP* TOP; /* Start executing at docol address, JMP* = jump to a non-relative address */
+ JMP* CX; /* Start executing at docol address, JMP* = jump to a non-relative address */
#define PUSH(r) SUBQ $8, PSP; \
MOVQ r, (PSP)
@@ -238,11 +223,13 @@
/* TODO change to allow only fetches from a certain memory range */
TEXT fetch(SB), 1, $-4 /* ( a -- n) */
+ ADDQ UP, TOP
MOVQ (TOP), TOP
NEXT
/* TODO change to allow stores to a certain memory range only */
TEXT store(SB), 1, $-4 /* ( n a -- ) */
+ ADDQ UP, TOP
POP(CX)
MOVQ CX, (TOP)
POP(TOP)
@@ -250,6 +237,7 @@
/* TODO change to allow only fetches from a certain memory range */
TEXT cfetch(SB), 1, $-4 /* ( a -- c ) */
+ ADDQ UP, TOP
XORQ CX, CX
MOVB (TOP), CL
POP(TOP)
@@ -257,6 +245,7 @@
/* TODO change to allow only fetches from a certain memory range */
TEXT cstore(SB), 1, $-4 /* ( c a -- ) */
+ ADDQ UP, TOP
POP(CX)
MOVB CL, (TOP)
POP(TOP)
@@ -553,44 +542,26 @@
ADDQ $PSTACK_END, TOP
NEXT
-/* store the forth sp here when going to C */
-TEXT forthsp(SB), 1, $-4
+TEXT h0(SB), 1, $-4 /* user pointer, start of heap */
PUSH(TOP)
MOVQ UP, TOP
- ADDQ $FORTHSP, TOP
NEXT
-/* variables used by the core words */
+TEXT args(SB), 1, $-4
+ PUSH(TOP)
+ MOVQ UP, TOP
+ ADDQ $ARGS, TOP
+ NEXT
+/*
+ * variables used by the core words. Using variable code word instead of known locations.
#define VARIABLE(name, location) TEXT name(SB), 1, $-4 ;\
PUSH(TOP); \
MOVQ UP, TOP ;\
ADDQ location, TOP ;\
NEXT;
-
VARIABLE(Tib, $TIB)
-VARIABLE(Wordb, $WORDB)
-VARIABLE(Hzero, $HEAPSTART)
-VARIABLE(Dp, $DP)
-VARIABLE(Dtop, $DTOP)
-VARIABLE(toIn, $TOIN)
-VARIABLE(toLimit, $TOLIMIT)
-VARIABLE(Findadr, $FINDADR)
-VARIABLE(Blk, $BLK)
-VARIABLE(Args, $ARGS)
-VARIABLE(Iobuf, $IOBUF)
-VARIABLE(Searchlen, $SEARCHLEN)
-VARIABLE(Base, $BASE)
-VARIABLE(toNum, $TONUM)
-VARIABLE(State, $STATE)
-VARIABLE(Abortvec, $ABORTVEC)
-VARIABLE(Sourcebuf, $SOURCEBUF)
-VARIABLE(Wordbuf, $WORDBUF)
-VARIABLE(Errstr, $ERRSTR)
-VARIABLE(Infd, $INFD)
-VARIABLE(Outfd, $OUTFD)
-VARIABLE(Errfd, $ERRFD)
-VARIABLE(Eof, $EOF)
+ */
TEXT forthend(SB), 1, $-4
--- a/os/pc64/primitives-nasm.s
+++ b/os/pc64/primitives-nasm.s
@@ -48,34 +48,35 @@
MENTRY "cmove", cmove, 5
MENTRY "cmove>", cmoveb, 6
- MENTRY "Tib", Tib, 3 ; variables from here, puts address on stack, mixed case
- MENTRY "Wordb", Wordb, 5
- MENTRY "Hzero", Hzero, 5
- MENTRY "Dp", Dp, 2
- MENTRY ">In", toIn, 3
- MENTRY ">Limit", toLimit, 6
- MENTRY "Findadr", Findadr, 7
- MENTRY "Blk", Blk, 3
- MENTRY "Args", Args, 4
- MENTRY "Iobuf", Iobuf, 5
- MENTRY "Searchlen", Searchlen, 9
- MENTRY "Base", Base, 4
- MENTRY ">Num", toNum, 4
- MENTRY "State", State, 5
- MENTRY "Abortvec", Abortvec, 8 ; not sure if these 3 can be constants instead?
- MENTRY "Sourcebuf", Sourcebuf, 9
- MENTRY "Wordbuf", Wordbuf, 7
- MENTRY "Infd", Infd, 5
- MENTRY "Outfd", Outfd, 6
- MENTRY "Errfd", Errfd, 4
- MENTRY "Eof", Eof, 0, 3
+ MVENTRY "Dp", Dp, 0, 2 ; cannot use H as it is nil in inferno, next available cell for the dictionary
+ MVENTRY "Dtop", Dtop, centry_c_boot(SB),4 ; cannot use H as it is nil in inferno, next available cell for the dictionary
+ MVENTRY "Iobuf", Iobuf, 0, 5
+ MVENTRY "Sourcebuf", Sourcebuf, 0, 9 ; is there a need for this?
+ MVENTRY "Wordbuf", Wordbuf, 0, 7 ; is there a need for this?
+ MVENTRY ">In", toIn, 0, 3
+ MVENTRY ">Limit", toLimit, 0, 6
+ MVENTRY "Findadr", Findadr, 0, 7
+ MVENTRY "Blk", Blk, 0, 3
+ MVENTRY "Searchlen", Searchlen, 0, 9
+ MVENTRY "Base", Base, 0, 4
+ MVENTRY ">Num", toNum, 0, 4
+ MVENTRY "State", State, 0, 5
+ MVENTRY "Abortvec", Abortvec, 0, 8 ; not sure if these 3 can be constants instead?
+ MVENTRY "Infd", Infd, 0, 5
+ MVENTRY "Outfd", Outfd, 0, 6
+ MVENTRY "Errfd", Errfd, 0, 4
+ MVENTRY "Eof", Eof, 0, 3
MCENTRY "STDIN", STDIN, 0, 5 ; 3 constants from here, CAPITALS
MCENTRY "STDOUT", STDOUT, 1, 6
MCENTRY "STDERR", STDERR, 2, 6
+ MCENTRY "WORDB", WORDB, WORDB, 5
+ MCENTRY "TIB", TIB, TIB, 3
MENTRY "s0", s0, 2
MENTRY "s@", stackptr, 2 ; puts PSP on stack
+ MENTRY "h0", h0, 2
+ MENTRY "args", args, 3
MENTRY "(variable)", variable, 10
MENTRY "(constant)", constant, 10
MENTRY "(:)", colon, 3
--- a/os/pc64/primitives.awk
+++ b/os/pc64/primitives.awk
@@ -67,6 +67,31 @@
tot += 8;
addrlabel = sprintf("mcentry_%s", label)
}
+$2 == "MVENTRY" {
+ if(label != ""){
+ lines[++nlines]=sprintf("GLOBL %s, $%d\n", last, tot);
+ }
+ gsub(/"/,"", $3)
+ name = $3
+ label = $4
+ tot = 0
+ writelast("mventry", label, last)
+ last=sprintf("mventry_%s(SB)", label);
+ lines[++nlines]=sprintf("DATA mventry_%s+8(SB)/1, $%d\n", label, length(name));
+ for(i=1; i<=length(name); i++){
+ lines[++nlines]=sprintf("DATA mventry_%s+%d(SB)/1, $'%c'\n", label, 8+i, substr(name,i,1));
+ }
+ tot = 8+i;
+ # for alignment
+ if(tot%8 > 0)
+ tot += 8-(tot%8);
+ lines[++nlines]=sprintf("DATA mventry_%s+%d(SB)/8, $variable(SB)\n", label, tot);
+ lines[++nlines]=sprintf("#define mv_%s(SB) mventry_%s+%d(SB)\n", label, label, tot);
+ tot += 8;
+ lines[++nlines]=sprintf("DATA mventry_%s+%d(SB)/8, $%s\n", label, tot, $5);
+ tot += 8;
+ addrlabel = sprintf("mventry_%s", label)
+}
$1 ~ /:$/ && $1 !~ /^dict:$/ {
l=$1
gsub(/:$/,"",l)
--- a/os/pc64/words-nasm.s
+++ b/os/pc64/words-nasm.s
@@ -261,14 +261,14 @@
CENTRY `key`, c_key, 3 ; ( -- c ) (G read a single character from the input onto the stack )
dd m_literal
dd 1 ; ( 1 -- )
- dd m_Iobuf ; variable iobuf to store the character read
- dd m_Infd
+ dd mv_Iobuf ; variable iobuf to store the character read
+ dd mv_Infd
dd m_fetch ; ( 1 Iobuf -- 1 Iobuf infd )
dd m_fthread ; ( 1 Iobuf infd -- n )
dd c_0eq
dd m_cjump ; if 0 characters read
dd L78 ; if qread n != 0, jump to L78. If n == 0, jump over
- dd m_Eof
+ dd mv_Eof
dd c_on ; EOF
dd m_literal
dd -1 ; return -1 when EOF
@@ -275,19 +275,19 @@
dd m_jump
dd L79
L78:
- dd m_Iobuf ; get the character from Iobuf to stack
+ dd mv_Iobuf ; get the character from Iobuf to stack
dd m_cfetch ; ( -- c ) return the character read if not EOF
L79:
dd m_exitcolon
CENTRY `emit`, c_emit, 4 ; ( character -- )
- dd m_Iobuf ; variable iobuf address
+ dd mv_Iobuf ; variable iobuf address
dd m_cstore ; variable iobuf has character
- dd m_Iobuf ; variable iobuf address
+ dd mv_Iobuf ; variable iobuf address
dd m_literal
dd 1
dd m_xswap ; ( iobuf 1 -- 1 iobuf )
- dd m_Outfd
+ dd mv_Outfd
dd m_fetch ; outfd
dd m_fthwrite ; ( 1 iobuf outfd -- )
dd m_exitcolon
@@ -402,12 +402,12 @@
dd c_fill
dd m_exitcolon
CENTRY `search`, c_search, 6
- dd m_Searchlen
+ dd mv_Searchlen
dd m_store
dd m_xswap
dd m_dup
dd m_rpush
- dd m_Searchlen
+ dd mv_Searchlen
dd m_fetch
dd m_minus
dd c_1plus
@@ -419,10 +419,10 @@
dd m_i
dd m_plus
dd m_over
- dd m_Searchlen
+ dd mv_Searchlen
dd m_fetch
dd m_xswap
- dd m_Searchlen
+ dd mv_Searchlen
dd m_fetch
dd c_compare
dd c_0eq
@@ -446,7 +446,7 @@
dd c_false
dd m_exitcolon
CENTRY `here`, c_here, 4
- dd m_Hzero
+ dd m_h0
dd m_fetch
dd m_exitcolon
CENTRY `,`, c_comma, 1
@@ -454,7 +454,7 @@
dd m_store
dd m_literal
dd 8
- dd m_Hzero
+ dd m_h0
dd c_plusstore
dd m_exitcolon
CENTRY `c,`, c_c, 2
@@ -462,11 +462,11 @@
dd m_cstore
dd m_literal
dd 1
- dd m_Hzero
+ dd m_h0
dd c_plusstore
dd m_exitcolon
CENTRY `allot`, c_allot, 5
- dd m_Hzero
+ dd m_h0
dd c_plusstore
dd m_exitcolon
CENTRY `pad`, c_pad, 3
@@ -478,11 +478,11 @@
CENTRY `align`, c_align, 5
dd c_here
dd c_aligned
- dd m_Hzero
+ dd m_h0
dd m_store
dd m_exitcolon
CENTRY `unused`, c_unused, 6
- dd m_Hzero
+ dd m_h0
dd m_fetch
dd c_here
dd m_minus
@@ -492,11 +492,11 @@
dd m_literal
dd 1024
dd m_plus
- dd m_toNum
+ dd mv_toNum
dd m_store
dd m_exitcolon
CENTRY `#`, c_hash, 1
- dd m_Base
+ dd mv_Base
dd m_fetch
dd m_uslashmod
dd m_xswap
@@ -519,11 +519,11 @@
dd 48
dd m_plus
L93:
- dd m_toNum
+ dd mv_toNum
dd m_fetch
dd c_1minus
dd m_dup
- dd m_toNum
+ dd mv_toNum
dd m_store
dd m_cstore
dd m_exitcolon
@@ -539,7 +539,7 @@
dd m_exitcolon
CENTRY `#>`, c_hashfrom, 2
dd m_drop
- dd m_toNum
+ dd mv_toNum
dd m_fetch
dd m_dup
dd c_pad
@@ -550,7 +550,7 @@
dd m_minus
dd m_exitcolon
CENTRY `hold`, c_hold, 4
- dd m_toNum
+ dd mv_toNum
dd m_fetch
dd c_1minus
dd m_dup
@@ -557,7 +557,7 @@
dd m_rpush
dd m_cstore
dd m_rpop
- dd m_toNum
+ dd mv_toNum
dd m_store
dd m_exitcolon
CENTRY `sign`, c_sign, 4
@@ -601,13 +601,13 @@
CENTRY `hex`, c_hex, 3
dd m_literal
dd 16
- dd m_Base
+ dd mv_Base
dd m_store
dd m_exitcolon
CENTRY `decimal`, c_decimal, 7
dd m_literal
dd 10
- dd m_Base
+ dd mv_Base
dd m_store
dd m_exitcolon
CENTRY `digit`, c_digit, 5
@@ -660,7 +660,7 @@
L109:
L107:
dd m_dup
- dd m_Base
+ dd mv_Base
dd m_fetch
dd m_less
dd m_cjump
@@ -705,7 +705,7 @@
dd 0
dd m_doinit
L117:
- dd m_Base
+ dd mv_Base
dd m_fetch
dd m_multiply
dd m_over
@@ -737,16 +737,16 @@
dd c_true
dd m_exitcolon
CENTRY `abort`, c_abort, 5
- dd m_Abortvec
+ dd mv_Abortvec
dd m_fetch
dd m_execute
dd m_exitcolon
CENTRY `source`, c_source, 6
- dd m_Sourcebuf
+ dd mv_Sourcebuf
dd m_fetch
dd m_exitcolon
CENTRY `current-input`, c_current_input, 13 ; ( -- c ) read the next character from the location in Sourcebuf
- dd m_toIn
+ dd mv_toIn
dd m_fetch
dd c_source
dd m_plus ; Sourcebuf + >In
@@ -753,14 +753,14 @@
dd m_cfetch
dd m_exitcolon
CENTRY `save-input`, c_save_input, 10
- dd m_Infd
- dd m_toIn
+ dd mv_Infd
+ dd mv_toIn
dd m_fetch
- dd m_toLimit
+ dd mv_toLimit
dd m_fetch
- dd m_Sourcebuf
+ dd mv_Sourcebuf
dd m_fetch
- dd m_Blk
+ dd mv_Blk
dd m_fetch
dd m_literal
dd 5
@@ -767,18 +767,18 @@
dd m_exitcolon
CENTRY `default-input`, c_default_input, 13
dd mc_STDIN
- dd m_toIn
+ dd mv_toIn
dd c_off
- dd m_toLimit
+ dd mv_toLimit
dd c_off
- dd m_Tib
- dd m_Sourcebuf
+ dd mc_TIB
+ dd mv_Sourcebuf
dd m_store
- dd m_Blk
+ dd mv_Blk
dd c_off
dd m_exitcolon
CENTRY `restore-input`, c_restore_input, 13
- dd m_Eof
+ dd mv_Eof
dd c_off
dd m_literal
dd 5
@@ -790,15 +790,15 @@
dd m_jump
dd L134
L133:
- dd m_Blk
+ dd mv_Blk
dd m_store
- dd m_Sourcebuf
+ dd mv_Sourcebuf
dd m_store
- dd m_toLimit
+ dd mv_toLimit
dd m_store
- dd m_toIn
+ dd mv_toIn
dd m_store
- dd m_Infd
+ dd mv_Infd
dd m_store
dd c_true
L134:
@@ -820,9 +820,9 @@
dd m_exitcolon
CENTRY `next-input`, c_next_input, 10 ; when >In < >Limit ( -- true c ). ( -- 0 false ) otherwise
- dd m_toIn
+ dd mv_toIn
dd m_fetch
- dd m_toLimit
+ dd mv_toLimit
dd m_fetch
dd m_less
dd m_cjump
@@ -840,7 +840,7 @@
CENTRY `parse`, c_parse, 5 ; ( c -- a ) Place the counted string in the address in Wordbuf and return that address. c = word delimiter.
dd m_rpush ; ( c -- ) (R -- c )
- dd m_Wordbuf
+ dd mv_Wordbuf
dd m_fetch ; ( -- Wordb )
dd c_1plus ; ( Wordb -- Wordb+1 )
L142:
@@ -856,7 +856,7 @@
dd c_1plus ; ( Wordb+1 -- Wordb+2 )
dd m_literal
dd 1
- dd m_toIn
+ dd mv_toIn
dd c_plusstore ; >In++
dd m_jump
dd L142 ; ( Wordb+2 ) repeat
@@ -863,11 +863,11 @@
L143: ; ( Wordb+1 ) >In >= >Limit || cinitial == cnew
dd m_literal
dd 1
- dd m_toIn
+ dd mv_toIn
dd c_plusstore ; >In++
dd m_rpop ; (Wordb+1 -- Wordb+1 c) (R c -- )
dd m_drop ; (Wordb+1 c -- Wordb+1)
- dd m_Wordbuf
+ dd mv_Wordbuf
dd m_fetch ; (Wordb+1 -- Wordb+1 Wordb)
dd m_dup ; (Wordb+1 Wordb -- Wordb+1 Wordb Wordb)
dd m_rpush ; (Wordb+1 Wordb Wordb -- Wordb+1 Wordb) (R -- Wordb)
@@ -889,7 +889,7 @@
dd L146 ; >In >= >Limit || cinitial != cnew
dd m_literal ; >In < >Limit && cinitial == cnew
dd 1
- dd m_toIn
+ dd mv_toIn
dd c_plusstore ; >In++
dd m_jump ; repeat
dd L145
@@ -940,15 +940,15 @@
dd m_exitcolon
CENTRY `query`, c_query, 5 ; read from input stream into the Text Input Buffer
- dd m_Eof
+ dd mv_Eof
dd c_off ; clear EOF flag
- dd m_Tib ; constant puts address of tibuffer on the top
+ dd mc_TIB ; constant puts address of tibuffer on the top
dd m_literal
dd 4096 ; ( tibuffer -- tibuffer 4096 )
dd c_accept ; ( tibuffer 4096 -- n )
dd m_dup ; ( n -- n n )
dd c_0eq ; ( n n -- n f )
- dd m_Eof
+ dd mv_Eof
dd m_fetch
dd m_binand ; n == 0 && EOF
dd m_cjump
@@ -958,15 +958,15 @@
dd m_jump
dd L153
L152: ; n > 0
- dd m_toLimit
+ dd mv_toLimit
dd m_store ; number of characters to read, >Limit = n
- dd m_toIn
+ dd mv_toIn
dd c_off ; start from 0, >In = 0
L153:
dd m_exitcolon
CENTRY `refill`, c_refill, 6
- dd m_Blk
+ dd mv_Blk
dd m_fetch
dd m_cjump
dd L155
@@ -980,9 +980,9 @@
dd m_exitcolon
CENTRY `findname`, c_findname, 8 ; ( a1 -- a2 f ) ; loop through the dictionary names
- dd m_Findadr
+ dd mv_Findadr
dd m_store
- dd m_Dp
+ dd mv_Dp
dd m_fetch ; get dictionary link
L158:
dd c_qdup
@@ -1006,7 +1006,7 @@
dd m_literal
dd 63
dd m_binand ; ( a1 a1+8+1 n 63 -- a1 a1+8+1 n&63 )
- dd m_Findadr
+ dd mv_Findadr
dd m_fetch
dd c_count ; ( a1 a1+8+1 n&63 a2 n2 -- a1 a1+8+1 n&63 a2+1 n2 )
dd c_compare ; ( -- a1 n ) compare dictionary entry with name
@@ -1022,7 +1022,7 @@
dd m_jump
dd L158
L159:
- dd m_Findadr
+ dd mv_Findadr
dd m_fetch
dd c_false
dd m_exitcolon
@@ -1139,7 +1139,7 @@
dd c_align
dd c_here
dd m_rpush
- dd m_Dp
+ dd mv_Dp
dd m_fetch
dd c_comma
dd c_bl
@@ -1160,7 +1160,7 @@
dd m_fetch
dd c_comma
dd m_rpop
- dd m_Dp
+ dd mv_Dp
dd m_store
dd m_exitcolon
CENTRY `variable`, c_variable, 8
@@ -1183,7 +1183,7 @@
dd c_comma
dd m_exitcolon
CENTRY `immediate`, c_immediate, 9
- dd m_Dp
+ dd mv_Dp
dd m_fetch
dd c_cellplus
dd m_dup
@@ -1250,7 +1250,7 @@
L191:
dd m_exitcolon
CENTRY `]`, c_close_bracket, 1
- dd m_State
+ dd mv_State
dd c_on
L196:
dd c_bl
@@ -1266,7 +1266,7 @@
dd L198
L197:
dd c_compile
- dd m_State
+ dd mv_State
dd m_fetch
L198:
dd m_cjump
@@ -1276,11 +1276,11 @@
L199:
dd m_exitcolon
CIENTRY `[`, ci_open_bracket, 1
- dd m_State
+ dd mv_State
dd c_off
dd m_exitcolon
CENTRY `smudge`, c_smudge, 6
- dd m_Dp
+ dd mv_Dp
dd m_fetch
dd c_cellplus
dd m_dup
@@ -1292,7 +1292,7 @@
dd m_cstore
dd m_exitcolon
CENTRY `reveal`, c_reveal, 6
- dd m_Dp
+ dd mv_Dp
dd m_fetch
dd c_cellplus
dd m_dup
@@ -1322,12 +1322,12 @@
dd m_literal
dd m_exitcolon
dd c_comma
- dd m_State
+ dd mv_State
dd c_off
dd c_reveal
dd m_exitcolon
CIENTRY `recurse`, ci_recurse, 7
- dd m_Dp
+ dd mv_Dp
dd m_fetch
dd c_cellplus
dd c_tocfa
@@ -1394,11 +1394,11 @@
dd m_drop
dd m_exitcolon
CIENTRY `\`, ci_backslash, 1
- dd m_Blk
+ dd mv_Blk
dd m_fetch
dd m_cjump
dd L214
- dd m_toIn
+ dd mv_toIn
dd m_fetch
dd m_literal
dd 63
@@ -1407,19 +1407,19 @@
dd 63
dd c_invert
dd m_binand
- dd m_toIn
+ dd mv_toIn
dd m_store
dd m_jump
dd L215
L214:
- dd m_toLimit
+ dd mv_toLimit
dd m_fetch
- dd m_toIn
+ dd mv_toIn
dd m_store
L215:
dd m_exitcolon
CENTRY `(?abort)`, c_qabort_parens, 8
- dd m_State
+ dd mv_State
dd m_cjump
dd L217
dd c_space
@@ -1669,9 +1669,9 @@
dd c_bl
dd c_word
dd m_rpush
- dd m_toLimit
+ dd mv_toLimit
dd m_fetch
- dd m_toIn
+ dd mv_toIn
dd m_store
dd c_save_input
dd m_rpop
@@ -1679,7 +1679,7 @@
dd c_ro
dd c_open_file
dd c_qfcheck
- dd m_Infd
+ dd mv_Infd
dd m_store
dd m_exitcolon
@@ -1704,21 +1704,21 @@
dd m_exitcolon ; why is this needed?
CENTRY `(abort)`, c_parenabort, 7 ; TODO correct below stack notations
- dd m_State ; ( m_State -- )
+ dd mv_State ; ( mv_State -- )
dd c_off ; off sets variable state = 0
- dd m_Tib ; constant puts address of tibuffer on the top of stack
- dd m_Sourcebuf ; variable sourcebuf
+ dd mc_TIB ; constant puts address of tibuffer on the top of stack
+ dd mv_Sourcebuf ; variable sourcebuf
dd m_store ; variable sourcebuf = address of tibuffer
- dd m_Blk ; variable blk
+ dd mv_Blk ; variable blk
dd c_off ; off variable blk = 0
dd mc_STDIN
- dd m_Infd
+ dd mv_Infd
dd m_store
dd mc_STDOUT
- dd m_Outfd
+ dd mv_Outfd
dd m_store
dd mc_STDERR
- dd m_Errfd
+ dd mv_Errfd
dd m_store
dd c_quit ; quit resets stacks and is the interpreter loop
dd m_exitcolon ; why is this needed? quit does not return unless it breaks
@@ -1729,7 +1729,7 @@
dd m_stackptr ; (D -- FFEND)
dd m_s0
dd m_store ; s0 = FFEND
- dd m_Hzero ; heaptop = heapend
+ dd m_h0 ; heaptop = heapend
dd m_fetch ; ( heapend -- )
dd m_literal
dd 1 ; ( heapend 1 -- )
@@ -1736,27 +1736,27 @@
dd c_cells ; cells ( heapend 8 -- )
dd m_minus ; ( heapend-8 -- )
dd m_fetch ; ( contents_from_heapend-8 -- )
- dd m_Args ; variable args
+ dd m_args ; variable args
dd m_store ; args = contents_from_heapend-8
dd m_literal
dd c_parenabort ; ( (abort) -- )
- dd m_Abortvec ; variable abortvec
+ dd mv_Abortvec ; variable abortvec
dd m_store ; variable abortvec = (abort) code address
- dd m_Wordb ; constant puts address of wordbuffer on the top of stack
- dd m_Wordbuf ; variable wordbuf
+ dd mc_WORDB ; constant puts address of wordbuffer on the top of stack
+ dd mv_Wordbuf ; variable wordbuf
dd m_store ; variable wordbuf = address of wordbuffer
- dd m_Tib ; constant puts address of tibuffer on the top of stack
- dd m_Sourcebuf ; variable sourcebuf
+ dd mc_TIB ; constant puts address of tibuffer on the top of stack
+ dd mv_Sourcebuf ; variable sourcebuf
dd m_store ; variable sourcebuf = address of tibuffer
dd m_literal
dd 0
- dd m_Infd
+ dd mv_Infd
dd m_store ; stdin = 0
dd m_literal
dd 1
- dd m_Outfd
+ dd mv_Outfd
dd m_store ; stdout = 1
- dd m_State
+ dd mv_State
dd c_off ; off stores 0 at state
dd c_decimal ; decimal setting base = 0
dd c_quit ; quit
@@ -1770,28 +1770,28 @@
dd m_literal
dd c_parenabort ; ( (abort) -- )
- dd m_Abortvec ; variable that puts (abort) code address on the stack
+ dd mv_Abortvec ; variable that puts (abort) code address on the stack
dd m_store ; variable abortvec = (abort) code address
- dd m_Wordb ; variable puts address of wordbuffer on the top of stack
- dd m_Wordbuf ; variable wordbuf
+ dd mc_WORDB ; variable puts address of wordbuffer on the top of stack
+ dd mv_Wordbuf ; variable wordbuf
dd m_store ; variable wordbuf = address of wordbuffer
- dd m_Tib ; constant puts address of tibuffer on the top of stack
- dd m_Sourcebuf ; variable sourcebuf
+ dd mc_TIB ; constant puts address of tibuffer on the top of stack
+ dd mv_Sourcebuf ; variable sourcebuf
dd m_store ; variable sourcebuf = address of tibuffer
dd mc_STDIN
- dd m_Infd
+ dd mv_Infd
dd m_store ; stdin = 0
dd mc_STDOUT
- dd m_Outfd
+ dd mv_Outfd
dd m_store
dd mc_STDERR
- dd m_Errfd
+ dd mv_Errfd
dd m_store
- dd m_State
+ dd mv_State
dd c_off ; off stores 0 at state
dd c_decimal ; decimal setting base = 0
dd c_quit ; quit