1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-09-29 14:20:55 +10:00

Add word "LITA"

This commit is contained in:
Virgil Dupras 2020-04-11 13:13:20 -04:00
parent 3822182226
commit af3db1c3cf
6 changed files with 46 additions and 8 deletions

View File

@ -43,6 +43,7 @@ DELW a -- Delete wordref at a. If it shadows another
DOES> -- See description at top of file DOES> -- See description at top of file
IMMED? a -- f Checks whether wordref at a is immediate. IMMED? a -- f Checks whether wordref at a is immediate.
IMMEDIATE -- Flag the latest defined word as immediate. IMMEDIATE -- Flag the latest defined word as immediate.
LITA n -- Write address n as a literal.
LITN n -- Write number n as a literal. LITN n -- Write number n as a literal.
VARIABLE c -- Creates cell x with 2 bytes allocation. VARIABLE c -- Creates cell x with 2 bytes allocation.

Binary file not shown.

View File

@ -25,7 +25,7 @@ JP(IY), NOP, ( 17, nativeWord )
0 JPnn, ( 1d, chkPS ) 0 JPnn, ( 1d, chkPS )
NOP, NOP, ( 20, numberWord ) NOP, NOP, ( 20, numberWord )
NOP, NOP, ( 22, litWord ) NOP, NOP, ( 22, litWord )
NOP, NOP, ( 24, unused ) NOP, NOP, ( 24, addrWord )
NOP, NOP, ( 26, unused ) NOP, NOP, ( 26, unused )
0 JPnn, ( 28, flagsToBC ) 0 JPnn, ( 28, flagsToBC )
0 JPnn, ( 2b, doesWord ) 0 JPnn, ( 2b, doesWord )
@ -334,7 +334,10 @@ PC ORG @ 0x2c + ! ( doesWord )
0x0e JPnn, ( 0e == compiledWord ) 0x0e JPnn, ( 0e == compiledWord )
( addrWord is the exact same thing as a numberWord except that
it is treated differently by meta-tools. See notes.txt )
PC ORG @ 0x20 + ! ( numberWord ) PC ORG @ 0x20 + ! ( numberWord )
PC ORG @ 0x24 + ! ( addrWord )
( This is not a word, but a number literal. This works a bit ( This is not a word, but a number literal. This works a bit
differently than others: PF means nothing and the actual differently than others: PF means nothing and the actual
number is placed next to the numberWord reference in the number is placed next to the numberWord reference in the

View File

@ -5,15 +5,15 @@
; ;
: [ INTERPRET 1 FLAGS ! ; IMMEDIATE : [ INTERPRET 1 FLAGS ! ; IMMEDIATE
: ] R> DROP ; : ] R> DROP ;
: LIT 34 , ; : LITS 34 , SCPY ;
: LITS LIT SCPY ;
: LIT< WORD LITS ; IMMEDIATE : LIT< WORD LITS ; IMMEDIATE
: LITA 36 , , ;
: ' : '
WORD (find) (?br) [ 4 , ] EXIT WORD (find) (?br) [ 4 , ] EXIT
LIT< (wnf) (find) DROP EXECUTE LIT< (wnf) (find) DROP EXECUTE
; ;
: ['] ' LITN ; IMMEDIATE : ['] ' LITA ; IMMEDIATE
: COMPILE ' LITN ['] , , ; IMMEDIATE : COMPILE ' LITA ['] , , ; IMMEDIATE
: [COMPILE] ' , ; IMMEDIATE : [COMPILE] ' , ; IMMEDIATE
: BEGIN H@ ; IMMEDIATE : BEGIN H@ ; IMMEDIATE
: AGAIN COMPILE (br) H@ - , ; IMMEDIATE : AGAIN COMPILE (br) H@ - , ; IMMEDIATE
@ -27,9 +27,10 @@
"_": words starting with "_" are meant to be "private", "_": words starting with "_" are meant to be "private",
that is, only used by their immediate surrondings. that is, only used by their immediate surrondings.
LIT: 34 == LIT LITS: 34 == litWord
LITA: 36 == addrWord
COMPILE: Tough one. Get addr of caller word (example above COMPILE: Tough one. Get addr of caller word (example above
(br)) and then call LITN on it. ) (br)) and then call LITA on it. )
: +! SWAP OVER @ + SWAP ! ; : +! SWAP OVER @ + SWAP ! ;
: -^ SWAP - ; : -^ SWAP - ;

View File

@ -14,7 +14,7 @@
; ;
: ." : ."
LIT 34 , ( 34 == litWord )
BEGIN BEGIN
C< DUP ( c c ) C< DUP ( c c )
( 34 is ASCII for " ) ( 34 is ASCII for " )

View File

@ -140,6 +140,39 @@ known usages:
* 0x70-0x78: ACIA buffer pointers in RC2014 recipes. * 0x70-0x78: ACIA buffer pointers in RC2014 recipes.
*** Word routines
This is the description of all word routine you can encounter in this Forth
implementation. That is, a wordref will always point to a memory offset
containing one of these numbers.
0x17: nativeWord. This words PFA contains native binary code and is jumped to
directly.
0x0e: compiledWord. This word's PFA contains an atom list and its execution is
described in "EXECUTION MODEL" above.
0x0b: cellWord. This word is usually followed by a 2-byte value in its PFA.
Upon execution, the *address* of the PFA is pushed to PS.
0x2b: doesWord. This word is created by "DOES>" and is followed by a 2-byte
value as well as the adress where "DOES>" was compiled. At that address is an
atom list exactly like in a compiled word. Upon execution, after having pushed
its cell addr to PSP, it execute its reference exactly like a compiledWord.
0x20: numberWord. No word is actually compiled with this routine, but atoms are.
Atoms with a reference to the number words routine are followed, *in the atom
list*, of a 2-byte number. Upon execution, that number is fetched and IP is
avdanced by an extra 2 bytes.
0x24: addrWord. Exactly like a numberWord, except that it is treated
differently by meta-tools.
0x22: litWord. Similar to a number word, except that instead of being followed
by a 2 byte number, it is followed by a null-terminated string. Upon execution,
the address of that null-terminated string is pushed on the PSP and IP is
advanced to the address following the null.
*** Initialization sequence *** Initialization sequence
On boot, we jump to the "main" routine in boot.fs which does very few things. On boot, we jump to the "main" routine in boot.fs which does very few things.