Implement TYPE and ."

This commit is contained in:
2026-03-01 18:02:02 +00:00
parent a9fd395a94
commit fac6c4d3b8

View File

@@ -101,6 +101,45 @@
2DROP
;
: TYPE ( addr len -- )
BEGIN
DUP 0= IF 2DROP EXIT THEN
SWAP DUP C@ EMIT 1+
SWAP 1-
AGAIN
;
: C, HERE @ C! 1 HERE +! ;
: ."
STATE @ IF
LIT BRANCH , \ Compile BRANCH for jumping over string data
HERE @ 0 , \ Compile placeholder offset and push offset cell address
0 BEGIN
KEY
DUP CHAR " = IF
DROP
HERE @ ALIGN HERE ! \ Pad to alignment
SWAP DUP HERE @ SWAP - \ Compute offset
OVER ! \ Update branch offset to skip data
4+ LIT LIT , , \ Append LIT <addr>
LIT LIT , , \ Append LIT <len>
LIT TYPE , \ Append TYPE
EXIT
THEN
C, 1+ \ Write byte and increment length
AGAIN
ELSE
BEGIN
KEY
DUP CHAR " = IF DROP EXIT THEN
EMIT
AGAIN
THEN
; IMMEDIATE
CHAR . EMIT
\ Set SYSREADY high to indicate prelude has finished and enable user
\ input on the JS side.