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

z80a: make mnemonic names more uniform across assemblers

Initially, I used the same letters as those used in the z80 ref
docs, but it makes the different assemblers harder to use than they
should. Having consistent "argtype" rules across assemblers should
help.
This commit is contained in:
Virgil Dupras 2020-06-27 22:01:56 -04:00
parent 490c57834f
commit 440ea43a88
83 changed files with 422 additions and 446 deletions

18
blk/201
View File

@ -3,14 +3,14 @@ Forth words, opcode assembly is a bit different than with a
typical assembler. For example, what would traditionally be typical assembler. For example, what would traditionally be
"ld a, b" would become "A B LDrr,". "ld a, b" would become "A B LDrr,".
BIN( is the addr at which the compiled binary will live. It is The "argtype" prefix after each mnemonic is needed because the
often 0. assembler doesn't auto-detect the op's form based on arguments.
It has to be explicitly specified. "r" is for 8-bit registers,
ORG is H@ offset at which we begin spitting binary. Used to "d" for 16-bit ones, "i" for immediate, "c" is for conditions.
compute PC. To have a proper PC, call "H@ ORG !" at the Be aware that "SP" and "AF" refer to the same value: some 16-
beginning of your assembly process. PC is H@ - ORG + BIN(. bit ops can affect SP, others, AF. If you use the wrong argu-
ment on the wrong op, you will affect the wrong register.
Mnemonics having only a single form, such as PUSH and POP,
don't have argtype prefixes.
(cont.) (cont.)

16
blk/202
View File

@ -1,3 +1,10 @@
BIN( is the addr at which the compiled binary will live. It is
often 0.
ORG is H@ offset at which we begin spitting binary. Used to
compute PC. To have a proper PC, call "H@ ORG !" at the
beginning of your assembly process. PC is H@ - ORG + BIN(.
Labels are a convenient way of managing relative jump Labels are a convenient way of managing relative jump
calculations. Backward labels are easy. It is only a matter or calculations. Backward labels are easy. It is only a matter or
recording "HERE" and do subtractions. Forward labels record the recording "HERE" and do subtractions. Forward labels record the
@ -6,11 +13,4 @@ that point later on, the label records the offset there.
To avoid using dict memory in compilation targets, we To avoid using dict memory in compilation targets, we
pre-declare label variables here, which means we have a limited pre-declare label variables here, which means we have a limited
number of it. For now, 4 ought to be enough. number of it. For now, 4 ought to be enough. (cont.)
(cont.)

22
blk/208
View File

@ -1,16 +1,16 @@
Instructions list Instructions list
r => A B C D E H L (HL) r => A B C D E H L (HL)
ss/qq => BC DE HL AF/SP d => BC DE HL AF/SP
cc => CNZ CZ CNC CC CPO CPE CP CM c => CNZ CZ CNC CC CPO CPE CP CM
LD [rr, rn, ddnn, (nn)HL, HL(nn), dd(nn), (nn)dd, rIXY, IXYr, LD [rr, ri, di, (i)HL, HL(i), d(i), (i)d, rIXY, IXYr,
(DE)A, A(DE)] (DE)A, A(DE)]
ADD [r, n, HLss, IXss, IXIX, IYss, IYIY] ADD [r, i, HLd, IXd, IXIX, IYd, IYIY]
ADC [r, HLss] ADC [r, HLd]
CP [r, n, (IXY+)] CP [r, i, (IXY+)]
SBC [r, HLss] SBC [r, HLd]
SUB [r, n] SUB [r, i]
PUSH [qq] POP [qq] PUSH POP
INC [r, ss, (IXY+)] DEC [r, ss, (IXY+)] INC [r, d, (IXY+)] DEC [r, d, (IXY+)]
AND [r, n] OR [r, n] XOR [r, n] (cont.) AND [r, i] OR [r, i] XOR [r, i] (cont.)

14
blk/209
View File

@ -1,11 +1,11 @@
(cont.) (cont.)
OUT [nA, (C)r] IN [An, r(C)] OUT [iA, (C)r] IN [Ai, r(C)]
SET [br] RES [br] BIT [br] SET RES BIT
RL [r] RLC [r] SLA [r] RLA RLCA RL RLC SLA RLA RLCA
RR [r] RRC [r] SRL [r] RRA RRCA RR RRC SRL RRA RRCA
CALL [nn] RST [n] DJNZ CALL RST DJNZ
JP [nn, (HL), (IX), (IY)] JP [i, (HL), (IX), (IY)]
JR [, Z, NZ, C, NC] JR [, Z, NZ, C, NC]
DI EI EXDEHL EXX HALT DI EI EXDEHL EXX HALT
NOP RET RETI RETN SCF NOP RET [,c] RETI RETN SCF

View File

@ -10,3 +10,5 @@
0x04 OP1r INCr, 0x05 OP1r DECr, 0x04 OP1r INCr, 0x05 OP1r DECr,
: INC(IXY+), INCr, A, ; : INC(IXY+), INCr, A, ;
: DEC(IXY+), DECr, A, ; : DEC(IXY+), DECr, A, ;
( also works for c )
0xc0 OP1r RETc,

12
blk/219
View File

@ -1,12 +1,6 @@
( also works for cc ) : OP1r0 ( r -- )
0xc0 OP1r RETcc, CREATE C, DOES>
( r -- ) C@ ( r op ) OR A, ;
: OP1r0
CREATE C,
DOES>
C@ ( r op )
OR A,
;
0x80 OP1r0 ADDr, 0x88 OP1r0 ADCr, 0x80 OP1r0 ADDr, 0x88 OP1r0 ADCr,
0xa0 OP1r0 ANDr, 0xb8 OP1r0 CPr, 0xa0 OP1r0 ANDr, 0xb8 OP1r0 CPr,
0xb0 OP1r0 ORr, 0x90 OP1r0 SUBr, 0xb0 OP1r0 ORr, 0x90 OP1r0 SUBr,

19
blk/220
View File

@ -1,15 +1,14 @@
( qq -- also works for ss ) : OP1d
: OP1qq
CREATE C, CREATE C,
DOES> DOES>
C@ ( qq op ) C@ ( d op )
SWAP ( op qq ) SWAP ( op d )
<<4 ( op qq<<4 ) <<4 ( op d<<4 )
OR A, OR A,
; ;
0xc5 OP1qq PUSHqq, 0xc1 OP1qq POPqq, 0xc5 OP1d PUSH, 0xc1 OP1d POP,
0x03 OP1qq INCss, 0x0b OP1qq DECss, 0x03 OP1d INCd, 0x0b OP1d DECd,
0x09 OP1qq ADDHLss, 0x09 OP1d ADDHLd,
: ADDIXss, 0xdd A, ADDHLss, ; : ADDIXIX, HL ADDIXss, ; : ADDIXd, 0xdd A, ADDHLd, ; : ADDIXIX, HL ADDIXd, ;
: ADDIYss, 0xfd A, ADDHLss, ; : ADDIYIY, HL ADDIYss, ; : ADDIYd, 0xfd A, ADDHLd, ; : ADDIYIY, HL ADDIYd, ;

19
blk/226
View File

@ -1,14 +1,13 @@
( n -- ) : OP2i ( i -- )
: OP2n
CREATE C, CREATE C,
DOES> DOES>
C@ A, A, C@ A, A,
; ;
0xd3 OP2n OUTnA, 0xd3 OP2i OUTiA,
0xdb OP2n INAn, 0xdb OP2i INAi,
0xc6 OP2n ADDn, 0xc6 OP2i ADDi,
0xe6 OP2n ANDn, 0xe6 OP2i ANDi,
0xf6 OP2n ORn, 0xf6 OP2i ORi,
0xd6 OP2n SUBn, 0xd6 OP2i SUBi,
0xee OP2n XORn, 0xee OP2i XORi,
0xfe OP2n CPn, 0xfe OP2i CPi,

11
blk/228
View File

@ -1,10 +1,9 @@
( r n -- ) : OP2ri ( r i -- )
: OP2rn
CREATE C, CREATE C,
DOES> DOES>
C@ ( r n op ) C@ ( r i op )
ROT ( n op r ) ROT ( i op r )
<<3 ( n op r<<3 ) <<3 ( i op r<<3 )
OR A, A, OR A, A,
; ;
0x06 OP2rn LDrn, 0x06 OP2ri LDri,

View File

@ -8,6 +8,6 @@
<<3 ( r op b<<3 ) <<3 ( r op b<<3 )
OR OR A, OR OR A,
; ;
0xc0 OP2br SETbr, 0xc0 OP2br SET,
0x80 OP2br RESbr, 0x80 OP2br RES,
0x40 OP2br BITbr, 0x40 OP2br BIT,

15
blk/232
View File

@ -1,15 +1,14 @@
( bitwise rotation ops have a similar sig ) ( bitwise rotation ops have a similar sig )
( r -- ) : OProt ( r -- )
: OProt
CREATE C, CREATE C,
DOES> DOES>
0xcb A, 0xcb A,
C@ ( r op ) C@ ( r op )
OR A, OR A,
; ;
0x10 OProt RLr, 0x10 OProt RL,
0x00 OProt RLCr, 0x00 OProt RLC,
0x18 OProt RRr, 0x18 OProt RR,
0x08 OProt RRCr, 0x08 OProt RRC,
0x20 OProt SLAr, 0x20 OProt SLA,
0x38 OProt SRLr, 0x38 OProt SRL,

11
blk/236
View File

@ -1,11 +1,10 @@
( ss -- ) : OP2d ( d -- )
: OP2ss
CREATE C, CREATE C,
DOES> DOES>
0xed A, 0xed A,
C@ SWAP ( op ss ) C@ SWAP ( op d )
<<4 ( op ss<< 4 ) <<4 ( op d<< 4 )
OR A, OR A,
; ;
0x4a OP2ss ADCHLss, 0x4a OP2d ADCHLd,
0x42 OP2ss SBCHLss, 0x42 OP2d SBCHLd,

12
blk/238
View File

@ -1,11 +1,11 @@
( dd nn -- ) ( d n -- )
: OP3ddnn : OP3dn
CREATE C, CREATE C,
DOES> DOES>
C@ ( dd nn op ) C@ ( d n op )
ROT ( nn op dd ) ROT ( n op d )
<<4 ( nn op dd<<4 ) <<4 ( n op d<<4 )
OR A, OR A,
A,, A,,
; ;
0x01 OP3ddnn LDddnn, 0x01 OP3dn LDdn,

12
blk/240
View File

@ -1,11 +1,11 @@
( nn -- ) ( n -- )
: OP3nn : OP3n
CREATE C, CREATE C,
DOES> DOES>
C@ A, C@ A,
A,, A,,
; ;
0xcd OP3nn CALLnn, 0xcd OP3n CALL,
0xc3 OP3nn JPnn, 0xc3 OP3n JP,
0x22 OP3nn LD(nn)HL, 0x22 OP3n LD(n)HL,
0x2a OP3nn LDHL(nn), 0x2a OP3n LDHL(n),

View File

@ -1,14 +1,14 @@
: LDdd(nn), ( dd nn -- ) : LDdd(n), ( d n -- )
0xed A, 0xed A,
SWAP <<4 0x4b OR A, SWAP <<4 0x4b OR A,
A,, A,,
; ;
: LD(nn)dd, ( nn dd -- ) : LD(n)d, ( n d -- )
0xed A, 0xed A,
<<4 0x43 OR A, <<4 0x43 OR A,
A,, A,,
; ;
: RSTn, 0xc7 OR A, ; : RST, 0xc7 OR A, ;
: JP(IX), IX DROP JP(HL), ; : JP(IX), IX DROP JP(HL), ;
: JP(IY), IY DROP JP(HL), ; : JP(IY), IY DROP JP(HL), ;

12
blk/243
View File

@ -1,12 +1,12 @@
: JPccnn, SWAP <<3 0xc2 OR A, A,, ; : JPc, SWAP <<3 0xc2 OR A, A,, ;
: BCALL, BIN( @ + CALLnn, ; : BCALL, BIN( @ + CALL, ;
: BJP, BIN( @ + JPnn, ; : BJP, BIN( @ + JP, ;
: BJPcc, BIN( @ + JPccnn, ; : BJPc, BIN( @ + JPc, ;
VARIABLE lblchkPS VARIABLE lblchkPS
: chkPS, lblchkPS @ CALLnn, ; ( chkPS, B305 ) : chkPS, lblchkPS @ CALL, ; ( chkPS, B305 )
CREATE lblnext 0 , ( stable ABI until set in B300 ) CREATE lblnext 0 , ( stable ABI until set in B300 )
: JPNEXT, lblnext @ ?DUP IF JPnn, ELSE 0x1a BJP, THEN ; : JPNEXT, lblnext @ ?DUP IF JP, ELSE 0x1a BJP, THEN ;
: CODE ( same as CREATE, but with native word ) : CODE ( same as CREATE, but with native word )
(entry) 0 C, ( 0 == native ) ; (entry) 0 C, ( 0 == native ) ;
: ;CODE JPNEXT, ; : ;CODE JPNEXT, ;

16
blk/249
View File

@ -1,12 +1,12 @@
( Macros ) ( Macros )
( clear carry + SBC ) ( clear carry + SBC )
: SUBHLss, A ORr, SBCHLss, ; : SUBHLd, A ORr, SBCHLd, ;
: PUSH0, BC 0 LDddnn, BC PUSHqq, ; : PUSH0, BC 0 LDdn, BC PUSH, ;
: PUSH1, BC 1 LDddnn, BC PUSHqq, ; : PUSH1, BC 1 LDdn, BC PUSH, ;
: PUSHZ, BC 0 LDddnn, IFZ, BC INCss, THEN, BC PUSHqq, ; : PUSHZ, BC 0 LDdn, IFZ, BC INCd, THEN, BC PUSH, ;
: PUSHA, B 0 LDrn, C A LDrr, BC PUSHqq, ; : PUSHA, B 0 LDri, C A LDrr, BC PUSH, ;
: HLZ, A H LDrr, L ORr, ; : HLZ, A H LDrr, L ORr, ;
: DEZ, A D LDrr, E ORr, ; : DEZ, A D LDrr, E ORr, ;
: LDDE(HL), E (HL) LDrr, HL INCss, D (HL) LDrr, ; : LDDE(HL), E (HL) LDrr, HL INCd, D (HL) LDrr, ;
: OUTHL, DUP A H LDrr, OUTnA, A L LDrr, OUTnA, ; : OUTHL, DUP A H LDrr, OUTiA, A L LDrr, OUTiA, ;
: OUTDE, DUP A D LDrr, OUTnA, A E LDrr, OUTnA, ; : OUTDE, DUP A D LDrr, OUTiA, A E LDrr, OUTiA, ;

12
blk/283
View File

@ -1,14 +1,14 @@
H@ ORG ! H@ ORG !
0 JPnn, ( 00, main ) NOP, ( unused ) NOP, NOP, ( 04, BOOT ) 0 JP, ( 00, main ) NOP, ( unused ) NOP, NOP, ( 04, BOOT )
NOP, NOP, ( 06, uflw ) NOP, NOP, ( 08, LATEST ) NOP, NOP, ( 06, uflw ) NOP, NOP, ( 08, LATEST )
NOP, NOP, NOP, NOP, NOP, NOP, NOP, ( 0a, unused ) NOP, NOP, NOP, NOP, NOP, NOP, NOP, ( 0a, unused )
0 JPnn, ( 11, pushRS ) 0 JPnn, ( 14, popRS ) 0 JP, ( 11, pushRS ) 0 JP, ( 14, popRS )
NOP, NOP, NOP, ( unused ) NOP, NOP, NOP, ( unused )
0 JPnn, ( 1a, next ) NOP, NOP, NOP, ( unused ) 0 JP, ( 1a, next ) NOP, NOP, NOP, ( unused )
NOP, NOP, NOP, NOP, ( unused ) NOP, NOP, NOP, NOP, ( unused )
NOP, NOP, NOP, NOP, ( unused ) NOP, NOP, NOP, NOP, ( unused )
0 JPnn, ( RST 28 ) 0 JP, ( RST 28 )
NOP, NOP, NOP, NOP, NOP, ( unused ) NOP, NOP, NOP, NOP, NOP, ( unused )
0 JPnn, ( RST 30 ) 0 JP, ( RST 30 )
NOP, NOP, NOP, NOP, NOP, ( unused ) NOP, NOP, NOP, NOP, NOP, ( unused )
0 JPnn, ( RST 38 ) 0 JP, ( RST 38 )

View File

@ -7,10 +7,10 @@
H@ XCURRENT ! ( set current tip of dict, 0x42 ) H@ XCURRENT ! ( set current tip of dict, 0x42 )
0 A, ( native ) 0 A, ( native )
0x14 BCALL, ( popRS ) 0x14 BCALL, ( popRS )
HL PUSHqq, IY POPqq, ( --> IP ) HL PUSH, IY POP, ( --> IP )
JPNEXT, JPNEXT,
CODE (br) ( 0x53 ) CODE (br) ( 0x53 )
L2 BSET ( used in CBR ) L2 BSET ( used in CBR )
E 0 IY+ LDrIXY, D 1 IY+ LDrIXY, E 0 IY+ LDrIXY, D 1 IY+ LDrIXY,
DE ADDIYss, DE ADDIYd,
JPNEXT, JPNEXT,

View File

@ -1,10 +1,10 @@
CODE (?br) ( 0x67 ) CODE (?br) ( 0x67 )
HL POPqq, HL POP,
HLZ, HLZ,
JRZ, L2 BWR ( br + 1. False, branch ) JRZ, L2 BWR ( br + 1. False, branch )
L1 BSET ( loop will jump here ) L1 BSET ( loop will jump here )
( True, skip next 2 bytes and don't branch ) ( True, skip next 2 bytes and don't branch )
IY INCss, IY INCss, IY INCd, IY INCd,
JPNEXT, NOP, NOP, NOP, JPNEXT, NOP, NOP, NOP,
CODE (loop) ( 0x80 ) CODE (loop) ( 0x80 )
0 IX+ INC(IXY+), IFZ, 1 IX+ INC(IXY+), THEN, ( I++ ) 0 IX+ INC(IXY+), IFZ, 1 IX+ INC(IXY+), THEN, ( I++ )
@ -12,4 +12,4 @@ CODE (loop) ( 0x80 )
A 0 IX+ LDrIXY, 2 IX- CP(IXY+), JRNZ, L2 BWR ( branch ) A 0 IX+ LDrIXY, 2 IX- CP(IXY+), JRNZ, L2 BWR ( branch )
A 1 IX+ LDrIXY, 1 IX- CP(IXY+), JRNZ, L2 BWR ( branch ) A 1 IX+ LDrIXY, 1 IX- CP(IXY+), JRNZ, L2 BWR ( branch )
( don't branch ) ( don't branch )
IX DECss, IX DECss, IX DECss, IX DECss, JR, L1 BWR IX DECd, IX DECd, IX DECd, IX DECd, JR, L1 BWR

View File

@ -1,5 +1,5 @@
CODE 2>R ( 0xa9 ) CODE 2>R ( 0xa9 )
DE POPqq, HL POPqq, DE POP, HL POP,
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL, 17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
;CODE NOP, NOP, NOP, ;CODE NOP, NOP, NOP,
CODE (n) ( 0xbf, number literal ) CODE (n) ( 0xbf, number literal )
@ -8,7 +8,6 @@ CODE (n) ( 0xbf, number literal )
Read, push, then advance IP. ) Read, push, then advance IP. )
E 0 IY+ LDrIXY, E 0 IY+ LDrIXY,
D 1 IY+ LDrIXY, D 1 IY+ LDrIXY,
IY INCss, IY INCd, IY INCd,
IY INCss, DE PUSH,
DE PUSHqq,
;CODE ;CODE

10
blk/287
View File

@ -2,10 +2,10 @@ CODE (s) ( 0xd4, string literal )
( Like (n) but instead of being followed by a 2 bytes ( Like (n) but instead of being followed by a 2 bytes
number, it's followed by a string. When called, puts the number, it's followed by a string. When called, puts the
string's address on PS ) string's address on PS )
IY PUSHqq, HL POPqq, ( <-- IP ) IY PUSH, HL POP, ( <-- IP )
E (HL) LDrr, D 0 LDrn, E (HL) LDrr, D 0 LDri,
DE INCss, DE INCd,
DE ADDIYss, DE ADDIYd,
HL PUSHqq, HL PUSH,
;CODE ;CODE
( END OF STABLE ABI ) ( END OF STABLE ABI )

View File

@ -1,12 +1,12 @@
CODE >R CODE >R
HL POPqq, HL POP,
17 BCALL, ( 17 == pushRS ) 17 BCALL, ( 17 == pushRS )
;CODE ;CODE
CODE R> CODE R>
20 BCALL, ( 20 == popRS ) 20 BCALL, ( 20 == popRS )
HL PUSHqq, HL PUSH,
;CODE ;CODE
CODE 2R> CODE 2R>
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL, 20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
HL PUSHqq, DE PUSHqq, HL PUSH, DE PUSH,
;CODE ;CODE

View File

@ -2,7 +2,7 @@ lblfind BSET
( Find the entry corresponding to word name where (HL) points ( Find the entry corresponding to word name where (HL) points
to in dictionary having its tip at DE and sets DE to point to in dictionary having its tip at DE and sets DE to point
to that entry. Z if found, NZ if not. ) to that entry. Z if found, NZ if not. )
HL PUSHqq, HL PUSH,
( First, figure out string len ) ( First, figure out string len )
A (HL) LDrr, A ORr, A (HL) LDrr, A ORr,
( special case. zero len? we never find anything. ) ( special case. zero len? we never find anything. )
@ -10,6 +10,6 @@ lblfind BSET
( Let's do something weird: We'll hold HL by the *tail*. ( Let's do something weird: We'll hold HL by the *tail*.
Because of our dict structure and because we know our Because of our dict structure and because we know our
lengths, it's easier to compare starting from the end. ) lengths, it's easier to compare starting from the end. )
C A LDrr, B 0 LDrn, ( C holds our length ) C A LDrr, B 0 LDri, ( C holds our length )
BC ADDHLss, HL INCss, ( HL points to after-last-char ) BC ADDHLd, HL INCd, ( HL points to after-last-char )
( cont . ) ( cont . )

View File

@ -1,8 +1,8 @@
BEGIN, ( inner ) BEGIN, ( inner )
( DE is a wordref, first step, do our len correspond? ) ( DE is a wordref, first step, do our len correspond? )
HL PUSHqq, ( --> lvl 1 ) HL PUSH, ( --> lvl 1 )
DE PUSHqq, ( --> lvl 2 ) DE PUSH, ( --> lvl 2 )
DE DECss, DE DECd,
LDA(DE), LDA(DE),
0x7f ANDn, ( remove IMMEDIATE flag ) 0x7f ANDi, ( remove IMMEDIATE flag )
C CPr, ( cont. ) C CPr, ( cont. )

View File

@ -1,12 +1,12 @@
IFZ, IFZ,
( match, let's compare the string then ) ( match, let's compare the string then )
DE DECss, ( Skip prev field. One less because we ) DE DECd, ( Skip prev field. One less because we )
DE DECss, ( pre-decrement ) DE DECd, ( pre-decrement )
B C LDrr, ( loop C times ) B C LDrr, ( loop C times )
BEGIN, BEGIN,
( pre-decrement for easier Z matching ) ( pre-decrement for easier Z matching )
DE DECss, DE DECd,
HL DECss, HL DECd,
LDA(DE), LDA(DE),
(HL) CPr, (HL) CPr,
JRNZ, BREAK, JRNZ, BREAK,

14
blk/294
View File

@ -1,16 +1,16 @@
( At this point, Z is set if we have a match. In all cases, ( At this point, Z is set if we have a match. In all cases,
we want to pop HL and DE ) we want to pop HL and DE )
DE POPqq, ( <-- lvl 2 ) DE POP, ( <-- lvl 2 )
HL POPqq, ( <-- lvl 1 ) HL POP, ( <-- lvl 1 )
JRZ, L2 FWR ( end-B296, match? we're done! ) JRZ, L2 FWR ( end-B296, match? we're done! )
( no match, go to prev and continue ) ( no match, go to prev and continue )
HL PUSHqq, ( --> lvl 1 ) HL PUSH, ( --> lvl 1 )
DE DECss, DE DECd, DE DECd, DE DECd, ( prev field )
DE DECss, DE PUSH, ( --> lvl 2 )
DE DECss, ( prev field )
DE PUSHqq, ( --> lvl 2 )
EXDEHL, EXDEHL,
LDDE(HL), LDDE(HL),
( cont. ) ( cont. )

View File

@ -1,14 +1,14 @@
( DE contains prev offset ) ( DE contains prev offset )
HL POPqq, ( <-- lvl 2 ) HL POP, ( <-- lvl 2 )
( HL is prev field's addr. Is offset zero? ) ( HL is prev field's addr. Is offset zero? )
DEZ, DEZ,
IFNZ, IFNZ,
( get absolute addr from offset ) ( get absolute addr from offset )
( carry cleared from "or e" ) ( carry cleared from "or e" )
DE SBCHLss, DE SBCHLd,
EXDEHL, ( result in DE ) EXDEHL, ( result in DE )
THEN, THEN,
HL POPqq, ( <-- lvl 1 ) HL POP, ( <-- lvl 1 )
JRNZ, AGAIN, ( inner-B292, try to match again ) JRNZ, AGAIN, ( inner-B292, try to match again )
( Z set? end of dict, unset Z ) ( Z set? end of dict, unset Z )

View File

@ -2,5 +2,5 @@
A XORr, A XORr,
A INCr, A INCr,
L2 FSET ( end ) L2 FSET ( end )
HL POPqq, HL POP,
RET, RET,

View File

@ -1,6 +1,5 @@
lblpushRS BSET PC ORG @ 0x12 + ! ( pushRS ) lblpushRS BSET PC ORG @ 0x12 + ! ( pushRS )
IX INCss, IX INCd, IX INCd,
IX INCss,
0 IX+ L LDIXYr, 0 IX+ L LDIXYr,
1 IX+ H LDIXYr, 1 IX+ H LDIXYr,
RET, RET,
@ -8,6 +7,5 @@ lblpushRS BSET PC ORG @ 0x12 + ! ( pushRS )
PC ORG @ 0x15 + ! ( popRS ) PC ORG @ 0x15 + ! ( popRS )
L 0 IX+ LDrIXY, L 0 IX+ LDrIXY,
H 1 IX+ LDrIXY, H 1 IX+ LDrIXY,
IX DECss, IX DECd, IX DECd,
IX DECss,
RET, RET,

View File

@ -1,3 +1,3 @@
lblofl BSET ( abortUnderflow ) lblofl BSET ( abortUnderflow )
DE BIN( @ 0x06 ( uflw ) + LDdd(nn), DE BIN( @ 0x06 ( uflw ) + LDdd(n),
JR, L2 FWR ( execute, B301 ) JR, L2 FWR ( execute, B301 )

12
blk/299
View File

@ -1,13 +1,13 @@
PC ORG @ 1 + ! ( main ) PC ORG @ 1 + ! ( main )
( STACK OVERFLOW PROTECTION: See B76 ) ( STACK OVERFLOW PROTECTION: See B76 )
SP PS_ADDR LDddnn, IX RS_ADDR LDddnn, SP PS_ADDR LDdn, IX RS_ADDR LDdn,
( HERE begins at RAMEND ) ( HERE begins at RAMEND )
HL RAMSTART 0x80 + LDddnn, HL RAMSTART 0x80 + LDdn,
RAMSTART 0x04 + LD(nn)HL, ( RAM+04 == HERE ) RAMSTART 0x04 + LD(n)HL, ( RAM+04 == HERE )
( LATEST is a label to the latest entry of the dict. It is ( LATEST is a label to the latest entry of the dict. It is
written at offset 0x08 by the process or person building written at offset 0x08 by the process or person building
Forth. ) Forth. )
BIN( @ 0x08 + LDHL(nn), BIN( @ 0x08 + LDHL(n),
RAMSTART 0x02 ( CURRENT ) + LD(nn)HL, RAMSTART 0x02 ( CURRENT ) + LD(n)HL,
DE BIN( @ 0x04 ( BOOT ) + LDdd(nn), DE BIN( @ 0x04 ( BOOT ) + LDdd(n),
JR, L1 FWR ( execute, B301 ) JR, L1 FWR ( execute, B301 )

12
blk/300
View File

@ -3,14 +3,14 @@ lblnext BSET PC ORG @ 0x1b + ! ( next )
we jump to current IP, but we also take care of increasing we jump to current IP, but we also take care of increasing
it by 2 before jumping. ) it by 2 before jumping. )
( Before we continue: are stacks within bounds? ) ( Before we continue: are stacks within bounds? )
( PS ) HL PS_ADDR LDddnn, ( PS ) HL PS_ADDR LDdn,
SP SUBHLss, SP SUBHLd,
JRC, lblofl BWR ( abortUnderflow-B298 ) JRC, lblofl BWR ( abortUnderflow-B298 )
( RS ) IX PUSHqq, HL POPqq, ( RS ) IX PUSH, HL POP,
DE RS_ADDR LDddnn, DE RS_ADDR LDdn,
DE SUBHLss, DE SUBHLd,
JRC, lblofl BWR ( IX < RS_ADDR? abortUnderflow-B298 ) JRC, lblofl BWR ( IX < RS_ADDR? abortUnderflow-B298 )
E 0 IY+ LDrIXY, E 0 IY+ LDrIXY,
D 1 IY+ LDrIXY, D 1 IY+ LDrIXY,
IY INCss, IY INCss, IY INCd, IY INCd,
( continue to execute ) ( continue to execute )

View File

@ -3,11 +3,11 @@ lblexec BSET L1 FSET ( B299 ) L2 FSET ( B298 )
( We don't apply BIN( reliably on stable ABI stuff, we ( We don't apply BIN( reliably on stable ABI stuff, we
might need to adjust addr. Ugly, but well... ) might need to adjust addr. Ugly, but well... )
BIN( @ [IF] BIN( @ [IF]
A XORr, D ORr, IFZ, D BIN( @ 256 / LDrn, THEN, A XORr, D ORr, IFZ, D BIN( @ 256 / LDri, THEN,
[THEN] [THEN]
LDA(DE), DE INCss, LDA(DE), DE INCd,
A ORr, IFZ, EXDEHL, JP(HL), THEN, A ORr, IFZ, EXDEHL, JP(HL), THEN,
A DECr, JRZ, L1 FWR ( compiled B303 ) A DECr, JRZ, L1 FWR ( compiled B303 )
( cell or does. push PFA ) DE PUSHqq, ( cell or does. push PFA ) DE PUSH,
A DECr, JRZ, lblnext BWR ( cell ) A DECr, JRZ, lblnext BWR ( cell )
( continue to does, B302 ) ( continue to does, B302 )

View File

@ -5,9 +5,8 @@
linkfrom the PFA, and then continue as a regular linkfrom the PFA, and then continue as a regular
compiledWord. ) compiledWord. )
EXDEHL, EXDEHL,
HL INCss, HL INCd, HL INCd,
HL INCss,
E (HL) LDrr, E (HL) LDrr,
HL INCss, HL INCd,
D (HL) LDrr, D (HL) LDrr,
( continue to compiledWord ) ( continue to compiledWord )

View File

@ -2,11 +2,11 @@
( 1. Push current IP to RS ( 1. Push current IP to RS
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 PUSH, HL POP, ( <-- IP )
lblpushRS @ ( pushRS ) CALLnn, lblpushRS @ ( pushRS ) CALL,
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),
HL INCss, HL INCd,
HL PUSHqq, IY POPqq, ( --> IP ) HL PUSH, IY POP, ( --> IP )
JR, lblexec BWR ( execute-B301 ) JR, lblexec BWR ( execute-B301 )

View File

@ -4,9 +4,9 @@ lblchkPS BSET ( chkPS )
check in next ) check in next )
EXX, EXX,
( We have the return address for this very call on the stack ( We have the return address for this very call on the stack
and protected registers. 2 - is to compensate that. ) and protected registers. 2- is to compensate that. )
HL PS_ADDR 2 - LDddnn, HL PS_ADDR 2- LDdn,
SP SUBHLss, SP SUBHLd,
EXX, EXX,
CNC RETcc, ( PS_ADDR >= SP? good ) CNC RETc, ( PS_ADDR >= SP? good )
JR, lblofl BWR ( abortUnderflow-B298 ) JR, lblofl BWR ( abortUnderflow-B298 )

View File

@ -3,13 +3,12 @@
expected to be defined in platform-specific code. ) expected to be defined in platform-specific code. )
CODE EXECUTE CODE EXECUTE
DE POPqq, DE POP,
chkPS, chkPS,
JR, lblexec BWR ( execute-B301 ) JR, lblexec BWR ( execute-B301 )
( a b c -- b c a ) CODE ROT ( a b c -- b c a )
CODE ROT HL POP, ( C ) DE POP, ( B ) BC POP, ( A )
HL POPqq, ( C ) DE POPqq, ( B ) BC POPqq, ( A )
chkPS, chkPS,
DE PUSHqq, ( B ) HL PUSHqq, ( C ) BC PUSHqq, ( A ) DE PUSH, ( B ) HL PUSH, ( C ) BC PUSH, ( A )
;CODE ;CODE

18
blk/307
View File

@ -1,16 +1,14 @@
( a -- a a ) CODE DUP ( a -- a a )
CODE DUP HL POP, chkPS,
HL POPqq, chkPS, HL PUSH, HL PUSH,
HL PUSHqq, HL PUSHqq,
;CODE ;CODE
CODE ?DUP CODE ?DUP
HL POPqq, chkPS, HL POP, chkPS,
HL PUSHqq, HL PUSH,
HLZ, IFNZ, HL PUSHqq, THEN, HLZ, IFNZ, HL PUSH, THEN,
;CODE ;CODE
( a -- ) CODE DROP ( a -- )
CODE DROP HL POP,
HL POPqq,
;CODE ;CODE

View File

@ -1,8 +1,8 @@
( a b -- b a ) ( a b -- b a )
CODE SWAP CODE SWAP
HL POPqq, ( B ) HL POP, ( B )
DE POPqq, ( A ) DE POP, ( A )
chkPS, chkPS,
HL PUSHqq, ( B ) HL PUSH, ( B )
DE PUSHqq, ( A ) DE PUSH, ( A )
;CODE ;CODE

10
blk/309
View File

@ -1,9 +1,9 @@
( a b -- a b a ) ( a b -- a b a )
CODE OVER CODE OVER
HL POPqq, ( B ) HL POP, ( B )
DE POPqq, ( A ) DE POP, ( A )
chkPS, chkPS,
DE PUSHqq, ( A ) DE PUSH, ( A )
HL PUSHqq, ( B ) HL PUSH, ( B )
DE PUSHqq, ( A ) DE PUSH, ( A )
;CODE ;CODE

16
blk/310
View File

@ -1,15 +1,15 @@
CODE PICK CODE PICK
HL POPqq, HL POP,
( x2 ) ( x2 )
L SLAr, H RLr, L SLA, H RL,
SP ADDHLss, SP ADDHLd,
C (HL) LDrr, C (HL) LDrr,
HL INCss, HL INCd,
B (HL) LDrr, B (HL) LDrr,
( check PS range before returning ) ( check PS range before returning )
EXDEHL, EXDEHL,
HL PS_ADDR LDddnn, HL PS_ADDR LDdn,
DE SUBHLss, DE SUBHLd,
CC lblofl @ JPccnn, ( abortUnderflow-B298 ) CC lblofl @ JPc, ( abortUnderflow-B298 )
BC PUSHqq, BC PUSH,
;CODE ;CODE

10
blk/311
View File

@ -2,14 +2,14 @@
"1 2 3 4 4 (roll)" --> "1 3 4 4". No sanity checks, never "1 2 3 4 4 (roll)" --> "1 3 4 4". No sanity checks, never
call with 0. ) call with 0. )
CODE (roll) CODE (roll)
HL POPqq, HL POP,
B H LDrr, B H LDrr,
C L LDrr, C L LDrr,
SP ADDHLss, SP ADDHLd,
HL INCss, HL INCd,
D H LDrr, D H LDrr,
E L LDrr, E L LDrr,
HL DECss, HL DECd,
HL DECss, HL DECd,
LDDR, LDDR,
;CODE ;CODE

15
blk/312
View File

@ -1,13 +1,10 @@
( a b -- ) CODE 2DROP ( a b -- )
CODE 2DROP HL POP, HL POP,
HL POPqq,
HL POPqq,
;CODE ;CODE
( a b -- a b a b ) CODE 2DUP ( a b -- a b a b )
CODE 2DUP HL POP, ( b ) DE POP, ( a )
HL POPqq, ( b ) DE POPqq, ( a )
chkPS, chkPS,
DE PUSHqq, HL PUSHqq, DE PUSH, HL PUSH,
DE PUSHqq, HL PUSHqq, DE PUSH, HL PUSH,
;CODE ;CODE

10
blk/313
View File

@ -1,10 +1,10 @@
CODE S0 CODE S0
HL PS_ADDR LDddnn, HL PS_ADDR LDdn,
HL PUSHqq, HL PUSH,
;CODE ;CODE
CODE 'S CODE 'S
HL 0 LDddnn, HL 0 LDdn,
SP ADDHLss, SP ADDHLd,
HL PUSHqq, HL PUSH,
;CODE ;CODE

View File

@ -1,6 +1,6 @@
CODE AND CODE AND
HL POPqq, HL POP,
DE POPqq, DE POP,
chkPS, chkPS,
A E LDrr, A E LDrr,
L ANDr, L ANDr,
@ -8,5 +8,5 @@ CODE AND
A D LDrr, A D LDrr,
H ANDr, H ANDr,
H A LDrr, H A LDrr,
HL PUSHqq, HL PUSH,
;CODE ;CODE

View File

@ -1,6 +1,6 @@
CODE OR CODE OR
HL POPqq, HL POP,
DE POPqq, DE POP,
chkPS, chkPS,
A E LDrr, A E LDrr,
L ORr, L ORr,
@ -8,5 +8,5 @@ CODE OR
A D LDrr, A D LDrr,
H ORr, H ORr,
H A LDrr, H A LDrr,
HL PUSHqq, HL PUSH,
;CODE ;CODE

View File

@ -1,6 +1,6 @@
CODE XOR CODE XOR
HL POPqq, HL POP,
DE POPqq, DE POP,
chkPS, chkPS,
A E LDrr, A E LDrr,
L XORr, L XORr,
@ -8,5 +8,5 @@ CODE XOR
A D LDrr, A D LDrr,
H XORr, H XORr,
H A LDrr, H A LDrr,
HL PUSHqq, HL PUSH,
;CODE ;CODE

View File

@ -1,5 +1,5 @@
CODE NOT CODE NOT
HL POPqq, HL POP,
chkPS, chkPS,
HLZ, HLZ,
PUSHZ, PUSHZ,

16
blk/318
View File

@ -1,15 +1,15 @@
CODE + CODE +
HL POPqq, HL POP,
DE POPqq, DE POP,
chkPS, chkPS,
DE ADDHLss, DE ADDHLd,
HL PUSHqq, HL PUSH,
;CODE ;CODE
CODE - CODE -
DE POPqq, DE POP,
HL POPqq, HL POP,
chkPS, chkPS,
DE SUBHLss, DE SUBHLd,
HL PUSHqq, HL PUSH,
;CODE ;CODE

16
blk/319
View File

@ -1,16 +1,16 @@
CODE * ( DE * BC -> DE (high) and HL (low) ) CODE * ( DE * BC -> DE (high) and HL (low) )
DE POPqq, BC POPqq, chkPS, DE POP, BC POP, chkPS,
HL 0 LDddnn, HL 0 LDdn,
A 0x10 LDrn, A 0x10 LDri,
( loop ) ( loop )
HL ADDHLss, HL ADDHLd,
E RLr, D RLr, E RL, D RL,
JRNC, 4 A, ( noinc ) JRNC, 4 A, ( noinc )
BC ADDHLss, BC ADDHLd,
JRNC, 1 A, ( noinc ) JRNC, 1 A, ( noinc )
DE INCss, DE INCd,
( noinc ) ( noinc )
A DECr, A DECr,
JRNZ, -14 A, ( loop ) JRNZ, -14 A, ( loop )
HL PUSHqq, HL PUSH,
;CODE ;CODE

View File

@ -2,12 +2,12 @@
( Divides AC by DE and places the quotient in AC and the ( Divides AC by DE and places the quotient in AC and the
remainder in HL ) remainder in HL )
CODE /MOD CODE /MOD
DE POPqq, DE POP,
BC POPqq, BC POP,
chkPS, chkPS,
A B LDrr, A B LDrr,
B 16 LDrn, B 16 LDri,
HL 0 LDddnn, HL 0 LDdn,

12
blk/321
View File

@ -1,15 +1,15 @@
BEGIN, ( loop ) BEGIN, ( loop )
SCF, SCF,
C RLr, C RL,
RLA, RLA,
HL ADCHLss, HL ADCHLd,
DE SBCHLss, DE SBCHLd,
IFC, IFC,
DE ADDHLss, DE ADDHLd,
C DECr, C DECr,
THEN, THEN,
DJNZ, AGAIN, ( loop ) DJNZ, AGAIN, ( loop )
B A LDrr, B A LDrr,
HL PUSHqq, HL PUSH,
BC PUSHqq, BC PUSH,
;CODE ;CODE

12
blk/322
View File

@ -1,15 +1,15 @@
CODE ! CODE !
HL POPqq, HL POP,
DE POPqq, DE POP,
(HL) E LDrr, (HL) E LDrr,
HL INCss, HL INCd,
(HL) D LDrr, (HL) D LDrr,
;CODE ;CODE
CODE @ CODE @
HL POPqq, HL POP,
chkPS, chkPS,
E (HL) LDrr, E (HL) LDrr,
HL INCss, HL INCd,
D (HL) LDrr, D (HL) LDrr,
DE PUSHqq, DE PUSH,
;CODE ;CODE

10
blk/323
View File

@ -1,13 +1,13 @@
CODE C! CODE C!
HL POPqq, HL POP,
DE POPqq, DE POP,
(HL) E LDrr, (HL) E LDrr,
;CODE ;CODE
CODE C@ CODE C@
HL POPqq, HL POP,
chkPS, chkPS,
L (HL) LDrr, L (HL) LDrr,
H 0 LDrn, H 0 LDri,
HL PUSHqq, HL PUSH,
;CODE ;CODE

10
blk/324
View File

@ -1,13 +1,13 @@
CODE PC! CODE PC!
BC POPqq, BC POP,
HL POPqq, HL POP,
L OUT(C)r, L OUT(C)r,
;CODE ;CODE
CODE PC@ CODE PC@
BC POPqq, BC POP,
chkPS, chkPS,
H 0 LDrn, H 0 LDri,
L INr(C), L INr(C),
HL PUSHqq, HL PUSH,
;CODE ;CODE

View File

@ -1,15 +1,15 @@
CODE I CODE I
L 0 IX+ LDrIXY, L 0 IX+ LDrIXY,
H 1 IX+ LDrIXY, H 1 IX+ LDrIXY,
HL PUSHqq, HL PUSH,
;CODE ;CODE
CODE I' CODE I'
L 2 IX- LDrIXY, L 2 IX- LDrIXY,
H 1 IX- LDrIXY, H 1 IX- LDrIXY,
HL PUSHqq, HL PUSH,
;CODE ;CODE
CODE J CODE J
L 4 IX- LDrIXY, L 4 IX- LDrIXY,
H 3 IX- LDrIXY, H 3 IX- LDrIXY,
HL PUSHqq, HL PUSH,
;CODE ;CODE

View File

@ -3,9 +3,9 @@ CODE BYE
;CODE ;CODE
CODE (resSP) CODE (resSP)
SP PS_ADDR LDddnn, SP PS_ADDR LDdn,
;CODE ;CODE
CODE (resRS) CODE (resRS)
IX RS_ADDR LDddnn, IX RS_ADDR LDdn,
;CODE ;CODE

View File

@ -1,11 +1,11 @@
CODE S= CODE S=
DE POPqq, HL POPqq, chkPS, DE POP, HL POP, chkPS,
LDA(DE), LDA(DE),
(HL) CPr, (HL) CPr,
IFZ, ( same size? ) IFZ, ( same size? )
B A LDrr, ( loop A times ) B A LDrr, ( loop A times )
BEGIN, BEGIN,
HL INCss, DE INCss, HL INCd, DE INCd,
LDA(DE), LDA(DE),
(HL) CPr, (HL) CPr,
JRNZ, BREAK, ( not equal? break early. NZ is set. ) JRNZ, BREAK, ( not equal? break early. NZ is set. )

16
blk/329
View File

@ -1,15 +1,15 @@
CODE CMP CODE CMP
HL POPqq, HL POP,
DE POPqq, DE POP,
chkPS, chkPS,
DE SUBHLss, DE SUBHLd,
BC 0 LDddnn, BC 0 LDdn,
IFNZ, ( < or > ) IFNZ, ( < or > )
BC INCss, BC INCd,
IFNC, ( < ) IFNC, ( < )
BC DECss, BC DECd,
BC DECss, BC DECd,
THEN, THEN,
THEN, THEN,
BC PUSHqq, BC PUSH,
;CODE ;CODE

10
blk/330
View File

@ -1,15 +1,15 @@
CODE _find ( cur w -- a f ) CODE _find ( cur w -- a f )
HL POPqq, ( w ) HL POP, ( w )
DE POPqq, ( cur ) DE POP, ( cur )
chkPS, chkPS,
lblfind @ CALLnn, lblfind @ CALL,
IFNZ, IFNZ,
( not found ) ( not found )
HL PUSHqq, HL PUSH,
PUSH0, PUSH0,
JPNEXT, JPNEXT,
THEN, THEN,
( found ) ( found )
DE PUSHqq, DE PUSH,
PUSH1, PUSH1,
;CODE ;CODE

View File

@ -7,6 +7,6 @@ CODE 0 PUSH0, ;CODE
CODE 1 PUSH1, ;CODE CODE 1 PUSH1, ;CODE
CODE -1 CODE -1
HL -1 LDddnn, HL -1 LDdn,
HL PUSHqq, HL PUSH,
;CODE ;CODE

12
blk/332
View File

@ -1,13 +1,13 @@
CODE 1+ CODE 1+
HL POPqq, HL POP,
chkPS, chkPS,
HL INCss, HL INCd,
HL PUSHqq, HL PUSH,
;CODE ;CODE
CODE 1- CODE 1-
HL POPqq, HL POP,
chkPS, chkPS,
HL DECss, HL DECd,
HL PUSHqq, HL PUSH,
;CODE ;CODE

16
blk/333
View File

@ -1,15 +1,15 @@
CODE 2+ CODE 2+
HL POPqq, HL POP,
chkPS, chkPS,
HL INCss, HL INCd,
HL INCss, HL INCd,
HL PUSHqq, HL PUSH,
;CODE ;CODE
CODE 2- CODE 2-
HL POPqq, HL POP,
chkPS, chkPS,
HL DECss, HL DECd,
HL DECss, HL DECd,
HL PUSHqq, HL PUSH,
;CODE ;CODE

View File

@ -1,12 +1,12 @@
CODE RSHIFT ( n u -- n ) CODE RSHIFT ( n u -- n )
BC POPqq, ( u ) BC POP, ( u )
HL POPqq, ( n ) HL POP, ( n )
chkPS, chkPS,
B C LDrr, B C LDrr,
B INCr, B DECr, IFNZ, B INCr, B DECr, IFNZ,
BEGIN, BEGIN,
H SRLr, L RRr, H SRL, L RR,
DJNZ, AGAIN, DJNZ, AGAIN,
THEN, THEN,
HL PUSHqq, HL PUSH,
;CODE ;CODE

View File

@ -1,12 +1,12 @@
CODE LSHIFT ( n u -- n ) CODE LSHIFT ( n u -- n )
BC POPqq, ( u ) BC POP, ( u )
HL POPqq, ( n ) HL POP, ( n )
chkPS, chkPS,
B C LDrr, B C LDrr,
B INCr, B DECr, IFNZ, B INCr, B DECr, IFNZ,
BEGIN, BEGIN,
L SLAr, H RLr, L SLA, H RL,
DJNZ, AGAIN, DJNZ, AGAIN,
THEN, THEN,
HL PUSHqq, HL PUSH,
;CODE ;CODE

18
blk/493
View File

@ -1,16 +1,16 @@
CODE (key) CODE (key)
A 0x01 LDrn, ( @KEY ) A 0x01 LDri, ( @KEY )
0x28 RSTn, 0x28 RST,
PUSHA, PUSHA,
;CODE ;CODE
CODE (emit) CODE (emit)
BC POPqq, ( c == @DSP arg ) chkPS, BC POP, ( c == @DSP arg ) chkPS,
A 0x02 LDrn, ( @DSP ) A 0x02 LDri, ( @DSP )
0x28 RSTn, 0x28 RST,
;CODE ;CODE
CODE AT-XY CODE AT-XY
DE POPqq, H E LDrr, ( Y ) DE POP, H E LDrr, ( Y )
DE POPqq, L E LDrr, ( X ) chkPS, DE POP, L E LDrr, ( X ) chkPS,
A 0x0f LDrn, ( @VDCTL ) B 3 LDrn, ( setcur ) A 0x0f LDri, ( @VDCTL ) B 3 LDri, ( setcur )
0x28 RSTn, 0x28 RST,
;CODE ;CODE

12
blk/494
View File

@ -1,12 +1,12 @@
: LINES 24 ; : COLS 80 ; : LINES 24 ; : COLS 80 ;
CODE BYE CODE BYE
HL 0 LDddnn, HL 0 LDdn,
A 0x16 LDrn, ( @EXIT ) A 0x16 LDri, ( @EXIT )
0x28 RSTn, 0x28 RST,
CODE @DCSTAT ( drv -- f ) CODE @DCSTAT ( drv -- f )
BC POPqq, BC POP,
chkPS, chkPS,
A 0x28 LDrn, ( @DCSTAT ) A 0x28 LDri, ( @DCSTAT )
0x28 RSTn, 0x28 RST,
PUSHZ, PUSHZ,
;CODE ;CODE

10
blk/495
View File

@ -1,9 +1,9 @@
CODE @RDSEC ( drv cylsec addr -- f ) CODE @RDSEC ( drv cylsec addr -- f )
HL POPqq, HL POP,
DE POPqq, DE POP,
BC POPqq, BC POP,
chkPS, chkPS,
A 0x31 LDrn, ( @RDSEC ) A 0x31 LDri, ( @RDSEC )
0x28 RSTn, 0x28 RST,
PUSHZ, PUSHZ,
;CODE ;CODE

16
blk/496
View File

@ -1,16 +1,16 @@
CODE @WRSEC ( drv cylsec addr -- f ) CODE @WRSEC ( drv cylsec addr -- f )
HL POPqq, HL POP,
DE POPqq, DE POP,
BC POPqq, BC POP,
chkPS, chkPS,
A 0x35 LDrn, ( @WRSEC ) A 0x35 LDri, ( @WRSEC )
0x28 RSTn, 0x28 RST,
PUSHZ, PUSHZ,
;CODE ;CODE
CODE @GET ( a -- c f ) CODE @GET ( a -- c f )
DE POPqq, DE POP,
chkPS, chkPS,
A 0x03 LDrn, ( @GET ) A 0x03 LDri, ( @GET )
0x28 RSTn, 0x28 RST,
PUSHA, PUSHZ, PUSHA, PUSHZ,
;CODE ;CODE

View File

@ -1,8 +1,8 @@
CODE @PUT ( c a -- f ) CODE @PUT ( c a -- f )
DE POPqq, DE POP,
BC POPqq, BC POP,
chkPS, chkPS,
A 0x04 LDrn, ( @PUT ) A 0x04 LDri, ( @PUT )
0x28 RSTn, 0x28 RST,
PUSHZ, PUSHZ,
;CODE ;CODE

14
blk/502
View File

@ -2,15 +2,15 @@
(HL) we're going to write to. If it wasn't a 0x20, we put a (HL) we're going to write to. If it wasn't a 0x20, we put a
0xff mask. If it was a 0x20, we put a 0x7f mask. ) 0xff mask. If it was a 0x20, we put a 0x7f mask. )
: @GET, : @GET,
A 0x03 LDrn, ( @GET ) A 0x03 LDri, ( @GET )
DE COM_DRV_ADDR LDddnn, DE COM_DRV_ADDR LDdn,
0x28 RSTn, JRNZ, L2 FWR ( maybeerror ) 0x28 RST, JRNZ, L2 FWR ( maybeerror )
A ORr, A ORr,
CZ RETcc, ( Sending a straight NULL ends the comm. ) ; CZ RETc, ( Sending a straight NULL ends the comm. ) ;
: @PUT, ( @PUT that char back ) : @PUT, ( @PUT that char back )
C A LDrr, C A LDrr,
A 0x04 LDrn, ( @PUT ) A 0x04 LDri, ( @PUT )
0x28 RSTn, JRNZ, L3 FWR ( error ) 0x28 RST, JRNZ, L3 FWR ( error )
A C LDrr, ; A C LDrr, ;
H@ ORG ! H@ ORG !
HL DEST_ADDR LDddnn, ( cont. ) HL DEST_ADDR LDdn, ( cont. )

10
blk/503
View File

@ -1,15 +1,15 @@
BEGIN, BEGIN,
A 0xff LDrn, (HL) A LDrr, ( default mask ) A 0xff LDri, (HL) A LDrr, ( default mask )
L1 BSET ( loop2 ) @GET, @PUT, L1 BSET ( loop2 ) @GET, @PUT,
0x20 CPn, JRZ, L4 FWR ( escapechar ) 0x20 CPi, JRZ, L4 FWR ( escapechar )
( not an escape char, just apply the mask and write ) ( not an escape char, just apply the mask and write )
(HL) ANDr, (HL) A LDrr, (HL) ANDr, (HL) A LDrr,
HL INCss, HL INCd,
JR, AGAIN, JR, AGAIN,
L4 FSET ( escapechar, adjust by setting (hl) to 0x7f ) L4 FSET ( escapechar, adjust by setting (hl) to 0x7f )
7 (HL) RESbr, JR, L1 BWR ( loop2 ) 7 (HL) RES, JR, L1 BWR ( loop2 )
L2 FSET ( maybeerror, was it an error? ) L2 FSET ( maybeerror, was it an error? )
A ORr, JRZ, L1 BWR ( loop2, not an error ) A ORr, JRZ, L1 BWR ( loop2, not an error )
L3 FSET ( error ) L3 FSET ( error )
C A LDrr, ( error code from @GET/@PUT ) C A LDrr, ( error code from @GET/@PUT )
A 0x1a LDrn, ( @ERROR ) 0x28 RSTn, RET, A 0x1a LDri, ( @ERROR ) 0x28 RST, RET,

View File

@ -7,7 +7,7 @@
we have to. ) we have to. )
CODE _wait CODE _wait
BEGIN, BEGIN,
0x10 ( CMD ) INAn, 0x10 ( CMD ) INAi,
RLA, ( When 7th bit is clr, we can send a new cmd ) RLA, ( When 7th bit is clr, we can send a new cmd )
JRC, AGAIN, JRC, AGAIN,
;CODE ;CODE

12
blk/566
View File

@ -1,14 +1,14 @@
( Requires KBD_MEM, KBD_PORT ) ( Requires KBD_MEM, KBD_PORT )
( gm -- pm, get pressed keys mask for group mask gm ) ( gm -- pm, get pressed keys mask for group mask gm )
CODE _get CODE _get
HL POPqq, HL POP,
chkPS, chkPS,
DI, DI,
A 0xff LDrn, A 0xff LDri,
KBD_PORT OUTnA, KBD_PORT OUTiA,
A L LDrr, A L LDrr,
KBD_PORT OUTnA, KBD_PORT OUTiA,
KBD_PORT INAn, KBD_PORT INAi,
EI, EI,
L A LDrr, HL PUSHqq, L A LDrr, HL PUSH,
;CODE ;CODE

16
blk/583
View File

@ -1,16 +1,14 @@
(entry) ~ACIA ( Set RST 38 jump ) PC ORG @ 0x39 + ! (entry) ~ACIA ( Set RST 38 jump ) PC ORG @ 0x39 + !
AF PUSHqq, AF PUSH, HL PUSH, DE PUSH,
HL PUSHqq,
DE PUSHqq,
( Read our character from ACIA into our BUFIDX ) ( Read our character from ACIA into our BUFIDX )
ACIA_CTL INAn, ACIA_CTL INAi,
0x01 ANDn, ( is ACIA rcv buf full? ) 0x01 ANDi, ( is ACIA rcv buf full? )
IFNZ, IFNZ,
( correct interrupt cause ) ( correct interrupt cause )
( +2 == ACIAW> ) ( +2 == ACIAW> )
ACIA_MEM 2+ LDHL(nn), ACIA_MEM 2+ LDHL(n),
( is it == to ACIAR>? ) ( is it == to ACIAR>? )
( +0 == ACIAR> ) ( +0 == ACIAR> )
DE ACIA_MEM LDdd(nn), DE ACIA_MEM LDdd(n),
( carry cleared from ANDn above ) ( carry cleared from ANDi above )
DE SBCHLss, ( cont. ) DE SBCHLd, ( cont. )

12
blk/584
View File

@ -1,16 +1,16 @@
IFNZ, ( buffer full? ) IFNZ, ( buffer full? )
( no, continue ) ( no, continue )
DE ADDHLss, ( restore ACIAW> ) DE ADDHLd, ( restore ACIAW> )
( buffer not full, let's write ) ( buffer not full, let's write )
ACIA_IO INAn, ACIA_IO INAi,
(HL) A LDrr, (HL) A LDrr,
( advance W> ) ( advance W> )
HL INCss, HL INCd,
( +2 == ACIAW> ) ( +2 == ACIAW> )
ACIA_MEM 2+ LD(nn)HL, ACIA_MEM 2+ LD(n)HL,
( +6 == ACIA) ) ( +6 == ACIA) )
DE ACIA_MEM 6 + LDdd(nn), DE ACIA_MEM 6 + LDdd(n),
DE SUBHLss, DE SUBHLd,
( cont. ) ( cont. )

11
blk/585
View File

@ -1,14 +1,11 @@
IFZ, ( end of buffer reached? ) IFZ, ( end of buffer reached? )
( yes ) ( yes )
( +4 == ACIA( ) ( +4 == ACIA( )
ACIA_MEM 4 + LDHL(nn), ACIA_MEM 4 + LDHL(n),
( +2 == ACIAW> ) ( +2 == ACIAW> )
ACIA_MEM 2+ LD(nn)HL, ACIA_MEM 2+ LD(n)HL,
THEN, THEN,
THEN, THEN,
THEN, THEN,
DE POPqq, DE POP, HL POP, AF POP,
HL POPqq, EI, RETI,
AF POPqq,
EI,
RETI,

View File

@ -1,12 +1,12 @@
( Initiate SPI exchange with the SD card. n is the data to ( Initiate SPI exchange with the SD card. n is the data to
send. ) send. )
CODE _sdcSR ( n -- n ) CODE _sdcSR ( n -- n )
HL POPqq, HL POP,
chkPS, chkPS,
A L LDrr, A L LDrr,
SDC_SPI OUTnA, SDC_SPI OUTiA,
NOP, NOP, NOP, NOP,
SDC_SPI INAn, SDC_SPI INAi,
L A LDrr, L A LDrr,
HL PUSHqq, HL PUSH,
;CODE ;CODE

16
blk/603
View File

@ -1,16 +1,16 @@
CODE _sdcSel SDC_CSLOW OUTnA, ;CODE CODE _sdcSel SDC_CSLOW OUTiA, ;CODE
CODE _sdcDesel SDC_CSHIGH OUTnA, ;CODE CODE _sdcDesel SDC_CSHIGH OUTiA, ;CODE
( Computes n into crc c with polynomial 0x1021 ) ( Computes n into crc c with polynomial 0x1021 )
CODE _crc16 ( c n -- c ) CODE _crc16 ( c n -- c )
HL POPqq, ( n ) DE POPqq, ( c ) HL POP, ( n ) DE POP, ( c )
A L LDrr, D XORr, D A LDrr, A L LDrr, D XORr, D A LDrr,
B 8 LDrn, B 8 LDri,
BEGIN, BEGIN,
E SLAr, D RLr, E SLA, D RL,
IFC, ( msb is set, apply polynomial ) IFC, ( msb is set, apply polynomial )
A D LDrr, 0x10 XORn, D A LDrr, A D LDrr, 0x10 XORi, D A LDrr,
A E LDrr, 0x21 XORn, E A LDrr, A E LDrr, 0x21 XORi, E A LDrr,
THEN, THEN,
DJNZ, AGAIN, DJNZ, AGAIN,
DE PUSHqq, DE PUSH,
;CODE ;CODE

10
blk/623
View File

@ -1,10 +1,10 @@
: XYPOS [ VDP_MEM LITN ] ; : XYPOS [ VDP_MEM LITN ] ;
CODE _ctl ( a -- sends LSB then MSB ) CODE _ctl ( a -- sends LSB then MSB )
HL POPqq, chkPS, HL POP, chkPS,
A L LDrr, VDP_CTLPORT OUTnA, A L LDrr, VDP_CTLPORT OUTiA,
A H LDrr, VDP_CTLPORT OUTnA, A H LDrr, VDP_CTLPORT OUTiA,
;CODE ;CODE
CODE _data CODE _data
HL POPqq, chkPS, HL POP, chkPS,
A L LDrr, VDP_DATAPORT OUTnA, A L LDrr, VDP_DATAPORT OUTiA,
;CODE ;CODE

10
blk/624
View File

@ -1,9 +1,9 @@
CODE _blank ( this is way too slow in Forth ) CODE _blank ( this is way too slow in Forth )
A XORr, VDP_CTLPORT OUTnA, A XORr, VDP_CTLPORT OUTiA,
A 0x40 LDrn, VDP_CTLPORT OUTnA, A 0x40 LDri, VDP_CTLPORT OUTiA,
HL 0x4000 LDddnn, HL 0x4000 LDdn,
BEGIN, BEGIN,
A XORr, VDP_DATAPORT OUTnA, A XORr, VDP_DATAPORT OUTiA,
HL DECss, HLZ, HL DECd, HLZ,
JRNZ, AGAIN, JRNZ, AGAIN,
;CODE ;CODE

18
blk/633
View File

@ -1,15 +1,15 @@
CODE _status CODE _status
A 0b11111101 LDrn, ( TH output, unselected ) A 0b11111101 LDri, ( TH output, unselected )
PAD_CTLPORT OUTnA, PAD_CTLPORT OUTiA,
PAD_D1PORT INAn, PAD_D1PORT INAi,
0x3f ANDn, ( low 6 bits are good ) 0x3f ANDi, ( low 6 bits are good )
B A LDrr, ( let's store them ) B A LDrr, ( let's store them )
( Start and A are returned when TH is selected, in bits 5 and ( Start and A are returned when TH is selected, in bits 5 and
4. Well get them, left-shift them and integrate them to B. ) 4. Well get them, left-shift them and integrate them to B. )
A 0b11011101 LDrn, ( TH output, selected ) A 0b11011101 LDri, ( TH output, selected )
PAD_CTLPORT OUTnA, PAD_CTLPORT OUTiA,
PAD_D1PORT INAn, PAD_D1PORT INAi,
0b00110000 ANDn, 0b00110000 ANDi,
A SLAr, A SLAr, B ORr, A SLA, A SLA, B ORr,
PUSHA, PUSHA,
;CODE ;CODE