1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-26 19:28:06 +11:00

Compare commits

..

No commits in common. "3383a000404eabfe18cf79599effbf4d6d991f8e" and "abb4dc8bd726ecfaac68da12920f350ca4373060" have entirely different histories.

15 changed files with 76 additions and 51 deletions

View File

@ -11,5 +11,6 @@ CONSTANT x n -- Creates cell x that when called pushes its
DOES> -- See B17. DOES> -- See B17.
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.

16
blk/086
View File

@ -1,3 +1,4 @@
(cont.)
0x2b: doesWord. This word is created by "DOES>" and is followed 0x2b: doesWord. This word is created by "DOES>" and is followed
by a 2-byte value as well as the address where "DOES>" was by a 2-byte value as well as the address where "DOES>" was
compiled. At that address is an atom list exactly like in a compiled. At that address is an atom list exactly like in a
@ -5,12 +6,11 @@ compiled word. Upon execution, after having pushed its cell
addr to PSP, it execute its reference exactly like a addr to PSP, it execute its reference exactly like a
compiledWord. compiledWord.
Also note that word routines references in wordrefs are 1b. 0x20: numberWord. No word is actually compiled with this
This means that all word routine reference must live below routine, but atoms are. Atoms with a reference to the number
0x100 in boot binary. 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. (cont.)

16
blk/087 Normal file
View File

@ -0,0 +1,16 @@
(cont.)
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.
Also note that word routines references in wordrefs are 1b.
This means that all word routine reference must live below
0x100 in boot binary. This is why numberWord and addrWord are
squeezed where they are.

View File

@ -5,7 +5,7 @@
: JPNEXT, 26 BJP, ; ( 26 == next ) : JPNEXT, 26 BJP, ; ( 26 == next )
: chkPS, L4 @ CALLnn, ; ( chkPS, B305 ) : chkPS, L4 @ BCALL, ; ( chkPS, B305 )
: CODE ( same as CREATE, but with native word ) : CODE ( same as CREATE, but with native word )
(entry) (entry)

View File

@ -8,9 +8,9 @@ VARIABLE XCURRENT
: _xapply ( a -- a-off ) : _xapply ( a -- a-off )
DUP ORG @ > IF ORG @ - BIN( @ + THEN ; DUP ORG @ > IF ORG @ - BIN( @ + THEN ;
: X' XCON ' XCOFF ; : X' XCON ' XCOFF ;
: X['] XCON ' _xapply LITN XCOFF ; : X['] XCON ' _xapply LITA XCOFF ;
: XCOMPILE : XCOMPILE
XCON ' _xapply LITN XCON ' _xapply LITA
LIT< , FIND DROP _xapply , XCOFF ; LIT< , FIND DROP _xapply , XCOFF ;
: X[COMPILE] XCON ' _xapply , XCOFF ; : X[COMPILE] XCON ' _xapply , XCOFF ;

View File

@ -7,8 +7,8 @@ NOP, ( 0a, unused )
0 JPnn, ( 14, popRS ) 0 JPnn, ( 14, popRS )
EXDEHL, JP(HL), NOP, ( 17, nativeWord ) EXDEHL, JP(HL), NOP, ( 17, nativeWord )
0 JPnn, ( 1a, next ) 0 JPnn, ( unused ) 0 JPnn, ( 1a, next ) 0 JPnn, ( unused )
NOP, NOP, NOP, NOP, ( 20, unused ) NOP, NOP, ( 20, numberWord ) NOP, NOP, ( 22, litWord )
NOP, NOP, NOP, NOP, ( 24, unused ) NOP, NOP, ( 24, addrWord ) NOP, NOP, ( 26, unused )
0 JPnn, ( RST 28 ) 0 JPnn, ( RST 28 )
0 JPnn, ( 2b, doesWord ) NOP, NOP, ( 2e, unused ) 0 JPnn, ( 2b, doesWord ) NOP, NOP, ( 2e, unused )
0 JPnn, ( RST 30 ) 0 JPnn, ( RST 30 )

22
blk/286
View File

@ -1,14 +1,16 @@
CODE 2>R ( 0xa9 ) CODE 2>R ( 0xa9 )
DE POPqq, HL POPqq, DE POPqq, HL POPqq,
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL, 17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
;CODE NOP, NOP, NOP, ;CODE ( END OF STABLE ABI )
CODE (n) ( 0xbf, number literal ) CODE >R
( Literal value to push to stack is next to (n) reference HL POPqq,
in the atom list. That is where IP is currently pointing. 17 BCALL, ( 17 == pushRS )
Read, push, then advance IP. ) ;CODE
E 0 IY+ LDrIXY, CODE R>
D 1 IY+ LDrIXY, 20 BCALL, ( 20 == popRS )
IY INCss, HL PUSHqq,
IY INCss, ;CODE
DE PUSHqq, CODE 2R>
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
HL PUSHqq, DE PUSHqq,
;CODE ;CODE

27
blk/287
View File

@ -1,11 +1,16 @@
CODE (s) ( 0xd4, string literal ) ( See B85 for word routine impl notes )
( Like (n) but instead of being followed by a 2 bytes PC ORG @ 0x20 + ! ( numberWord )
number, it's followed by a string. When called, puts the PC ORG @ 0x24 + ! ( addrWord )
string's address on PS ) ( This is not a word, but a number literal. This works a bit
IY PUSHqq, HL POPqq, ( <-- IP ) differently than others: PF means nothing and the actual
E (HL) LDrr, D 0 LDrn, number is placed next to the numberWord reference in the
DE INCss, compiled word list. What we need to do to fetch that number
DE ADDIYss, is to play with the IP. )
HL PUSHqq, E 0 IY+ LDrIXY,
;CODE D 1 IY+ LDrIXY,
( END OF STABLE ABI ) IY INCss,
IY INCss,
DE PUSHqq,
JPNEXT,

22
blk/288
View File

@ -1,15 +1,15 @@
CODE >R PC ORG @ 0x22 + ! ( litWord, 0xf7, tight on the 0x100 limit )
HL POPqq, ( Like numberWord, but instead of being followed by a 2 bytes
17 BCALL, ( 17 == pushRS ) number, it's followed by a null-terminated string. When
;CODE called, puts the string's address on PS )
CODE R> IY PUSHqq, HL POPqq, ( <-- IP )
20 BCALL, ( 20 == popRS ) E (HL) LDrr, D 0 LDrn,
DE INCss,
DE ADDIYss,
HL PUSHqq, HL PUSHqq,
;CODE JPNEXT,
CODE 2R>
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
HL PUSHqq, DE PUSHqq,
;CODE

View File

@ -3,7 +3,7 @@ PC ORG @ 0x0f + ! ( compiledWord )
2. Set new IP to the second atom of the list 2. Set new IP to the second atom of the list
3. Execute the first atom of the list. ) 3. Execute the first atom of the list. )
IY PUSHqq, HL POPqq, ( <-- IP ) IY PUSHqq, HL POPqq, ( <-- IP )
L4 @ ( pushRS ) CALLnn, L4 @ ( pushRS ) BCALL,
EXDEHL, ( HL points to PFA ) EXDEHL, ( HL points to PFA )
( While we inc, dereference into DE for execute call later. ) ( While we inc, dereference into DE for execute call later. )
LDDE(HL), LDDE(HL),

View File

@ -3,7 +3,7 @@
C< DUP 34 ( ASCII " ) = IF DROP EXIT THEN C, C< DUP 34 ( ASCII " ) = IF DROP EXIT THEN C,
AGAIN ; AGAIN ;
: LIT" : LIT"
COMPILE (s) H@ 0 C, ," 34 , ( litWord ) H@ 0 C, ,"
DUP H@ -^ 1- ( a len ) SWAP C! DUP H@ -^ 1- ( a len ) SWAP C!
; IMMEDIATE ; IMMEDIATE
: ." [COMPILE] LIT" COMPILE (print) ; IMMEDIATE : ." [COMPILE] LIT" COMPILE (print) ; IMMEDIATE

View File

@ -3,7 +3,7 @@
: DO COMPILE 2>R H@ ; IMMEDIATE : DO COMPILE 2>R H@ ; IMMEDIATE
: LOOP COMPILE (loop) H@ - _bchk , ; IMMEDIATE : LOOP COMPILE (loop) H@ - _bchk , ; IMMEDIATE
( LEAVE is implemented in low xcomp ) ( LEAVE is implemented in low xcomp )
: LITN COMPILE (n) , ; : LITN 32 , , ( 32 == NUMBER ) ;
( gets its name at the very end. can't comment afterwards ) ( gets its name at the very end. can't comment afterwards )
: _ BEGIN LIT< ) WORD S= UNTIL ; IMMEDIATE : _ BEGIN LIT< ) WORD S= UNTIL ; IMMEDIATE
: _ ( : will get its name almost at the very end ) : _ ( : will get its name almost at the very end )

View File

@ -1,10 +1,11 @@
: LIT< COMPILE (s) WORD DUP C@ 1+ MOVE, ; IMMEDIATE : LIT< WORD 34 , DUP C@ 1+ MOVE, ; IMMEDIATE
: BEGIN H@ ; IMMEDIATE : BEGIN H@ ; IMMEDIATE
: AGAIN COMPILE (br) H@ - _bchk , ; IMMEDIATE : AGAIN COMPILE (br) H@ - _bchk , ; IMMEDIATE
: UNTIL COMPILE (?br) H@ - _bchk , ; IMMEDIATE : UNTIL COMPILE (?br) H@ - _bchk , ; IMMEDIATE
: [ INTERPRET ; IMMEDIATE : [ INTERPRET ; IMMEDIATE
: ] R> DROP ; : ] R> DROP ;
: COMPILE ' LITN ['] , , ; IMMEDIATE : LITA 36 , , ;
: COMPILE ' LITA ['] , , ; IMMEDIATE
: [COMPILE] ' , ; IMMEDIATE : [COMPILE] ' , ; IMMEDIATE

View File

@ -5,7 +5,7 @@
['] EXIT , ['] EXIT ,
R> DROP ( exit : ) R> DROP ( exit : )
; IMMEDIATE ; IMMEDIATE
: ['] ' LITN ; IMMEDIATE : ['] ' LITA ; IMMEDIATE
';' X' _ 4 - C! ( give ; its name ) ';' X' _ 4 - C! ( give ; its name )
':' X' _ 4 - C! ( give : its name ) ':' X' _ 4 - C! ( give : its name )
'(' X' _ 4 - C! '(' X' _ 4 - C!

Binary file not shown.