mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 20:08:05 +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:
parent
490c57834f
commit
440ea43a88
18
blk/201
18
blk/201
@ -3,14 +3,14 @@ Forth words, opcode assembly is a bit different than with a
|
||||
typical assembler. For example, what would traditionally be
|
||||
"ld a, b" would become "A B LDrr,".
|
||||
|
||||
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(.
|
||||
|
||||
|
||||
|
||||
The "argtype" prefix after each mnemonic is needed because the
|
||||
assembler doesn't auto-detect the op's form based on arguments.
|
||||
It has to be explicitly specified. "r" is for 8-bit registers,
|
||||
"d" for 16-bit ones, "i" for immediate, "c" is for conditions.
|
||||
Be aware that "SP" and "AF" refer to the same value: some 16-
|
||||
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.)
|
||||
|
16
blk/202
16
blk/202
@ -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
|
||||
calculations. Backward labels are easy. It is only a matter or
|
||||
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
|
||||
pre-declare label variables here, which means we have a limited
|
||||
number of it. For now, 4 ought to be enough.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(cont.)
|
||||
number of it. For now, 4 ought to be enough. (cont.)
|
||||
|
22
blk/208
22
blk/208
@ -1,16 +1,16 @@
|
||||
Instructions list
|
||||
|
||||
r => A B C D E H L (HL)
|
||||
ss/qq => BC DE HL AF/SP
|
||||
cc => CNZ CZ CNC CC CPO CPE CP CM
|
||||
d => BC DE HL AF/SP
|
||||
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)]
|
||||
ADD [r, n, HLss, IXss, IXIX, IYss, IYIY]
|
||||
ADC [r, HLss]
|
||||
CP [r, n, (IXY+)]
|
||||
SBC [r, HLss]
|
||||
SUB [r, n]
|
||||
PUSH [qq] POP [qq]
|
||||
INC [r, ss, (IXY+)] DEC [r, ss, (IXY+)]
|
||||
AND [r, n] OR [r, n] XOR [r, n] (cont.)
|
||||
ADD [r, i, HLd, IXd, IXIX, IYd, IYIY]
|
||||
ADC [r, HLd]
|
||||
CP [r, i, (IXY+)]
|
||||
SBC [r, HLd]
|
||||
SUB [r, i]
|
||||
PUSH POP
|
||||
INC [r, d, (IXY+)] DEC [r, d, (IXY+)]
|
||||
AND [r, i] OR [r, i] XOR [r, i] (cont.)
|
||||
|
14
blk/209
14
blk/209
@ -1,11 +1,11 @@
|
||||
(cont.)
|
||||
OUT [nA, (C)r] IN [An, r(C)]
|
||||
SET [br] RES [br] BIT [br]
|
||||
RL [r] RLC [r] SLA [r] RLA RLCA
|
||||
RR [r] RRC [r] SRL [r] RRA RRCA
|
||||
CALL [nn] RST [n] DJNZ
|
||||
JP [nn, (HL), (IX), (IY)]
|
||||
OUT [iA, (C)r] IN [Ai, r(C)]
|
||||
SET RES BIT
|
||||
RL RLC SLA RLA RLCA
|
||||
RR RRC SRL RRA RRCA
|
||||
CALL RST DJNZ
|
||||
JP [i, (HL), (IX), (IY)]
|
||||
JR [, Z, NZ, C, NC]
|
||||
|
||||
DI EI EXDEHL EXX HALT
|
||||
NOP RET RETI RETN SCF
|
||||
NOP RET [,c] RETI RETN SCF
|
||||
|
2
blk/218
2
blk/218
@ -10,3 +10,5 @@
|
||||
0x04 OP1r INCr, 0x05 OP1r DECr,
|
||||
: INC(IXY+), INCr, A, ;
|
||||
: DEC(IXY+), DECr, A, ;
|
||||
( also works for c )
|
||||
0xc0 OP1r RETc,
|
||||
|
12
blk/219
12
blk/219
@ -1,12 +1,6 @@
|
||||
( also works for cc )
|
||||
0xc0 OP1r RETcc,
|
||||
( r -- )
|
||||
: OP1r0
|
||||
CREATE C,
|
||||
DOES>
|
||||
C@ ( r op )
|
||||
OR A,
|
||||
;
|
||||
: OP1r0 ( r -- )
|
||||
CREATE C, DOES>
|
||||
C@ ( r op ) OR A, ;
|
||||
0x80 OP1r0 ADDr, 0x88 OP1r0 ADCr,
|
||||
0xa0 OP1r0 ANDr, 0xb8 OP1r0 CPr,
|
||||
0xb0 OP1r0 ORr, 0x90 OP1r0 SUBr,
|
||||
|
19
blk/220
19
blk/220
@ -1,15 +1,14 @@
|
||||
( qq -- also works for ss )
|
||||
: OP1qq
|
||||
: OP1d
|
||||
CREATE C,
|
||||
DOES>
|
||||
C@ ( qq op )
|
||||
SWAP ( op qq )
|
||||
<<4 ( op qq<<4 )
|
||||
C@ ( d op )
|
||||
SWAP ( op d )
|
||||
<<4 ( op d<<4 )
|
||||
OR A,
|
||||
;
|
||||
0xc5 OP1qq PUSHqq, 0xc1 OP1qq POPqq,
|
||||
0x03 OP1qq INCss, 0x0b OP1qq DECss,
|
||||
0x09 OP1qq ADDHLss,
|
||||
0xc5 OP1d PUSH, 0xc1 OP1d POP,
|
||||
0x03 OP1d INCd, 0x0b OP1d DECd,
|
||||
0x09 OP1d ADDHLd,
|
||||
|
||||
: ADDIXss, 0xdd A, ADDHLss, ; : ADDIXIX, HL ADDIXss, ;
|
||||
: ADDIYss, 0xfd A, ADDHLss, ; : ADDIYIY, HL ADDIYss, ;
|
||||
: ADDIXd, 0xdd A, ADDHLd, ; : ADDIXIX, HL ADDIXd, ;
|
||||
: ADDIYd, 0xfd A, ADDHLd, ; : ADDIYIY, HL ADDIYd, ;
|
||||
|
19
blk/226
19
blk/226
@ -1,14 +1,13 @@
|
||||
( n -- )
|
||||
: OP2n
|
||||
: OP2i ( i -- )
|
||||
CREATE C,
|
||||
DOES>
|
||||
C@ A, A,
|
||||
;
|
||||
0xd3 OP2n OUTnA,
|
||||
0xdb OP2n INAn,
|
||||
0xc6 OP2n ADDn,
|
||||
0xe6 OP2n ANDn,
|
||||
0xf6 OP2n ORn,
|
||||
0xd6 OP2n SUBn,
|
||||
0xee OP2n XORn,
|
||||
0xfe OP2n CPn,
|
||||
0xd3 OP2i OUTiA,
|
||||
0xdb OP2i INAi,
|
||||
0xc6 OP2i ADDi,
|
||||
0xe6 OP2i ANDi,
|
||||
0xf6 OP2i ORi,
|
||||
0xd6 OP2i SUBi,
|
||||
0xee OP2i XORi,
|
||||
0xfe OP2i CPi,
|
||||
|
11
blk/228
11
blk/228
@ -1,10 +1,9 @@
|
||||
( r n -- )
|
||||
: OP2rn
|
||||
: OP2ri ( r i -- )
|
||||
CREATE C,
|
||||
DOES>
|
||||
C@ ( r n op )
|
||||
ROT ( n op r )
|
||||
<<3 ( n op r<<3 )
|
||||
C@ ( r i op )
|
||||
ROT ( i op r )
|
||||
<<3 ( i op r<<3 )
|
||||
OR A, A,
|
||||
;
|
||||
0x06 OP2rn LDrn,
|
||||
0x06 OP2ri LDri,
|
||||
|
6
blk/230
6
blk/230
@ -8,6 +8,6 @@
|
||||
<<3 ( r op b<<3 )
|
||||
OR OR A,
|
||||
;
|
||||
0xc0 OP2br SETbr,
|
||||
0x80 OP2br RESbr,
|
||||
0x40 OP2br BITbr,
|
||||
0xc0 OP2br SET,
|
||||
0x80 OP2br RES,
|
||||
0x40 OP2br BIT,
|
||||
|
15
blk/232
15
blk/232
@ -1,15 +1,14 @@
|
||||
( bitwise rotation ops have a similar sig )
|
||||
( r -- )
|
||||
: OProt
|
||||
: OProt ( r -- )
|
||||
CREATE C,
|
||||
DOES>
|
||||
0xcb A,
|
||||
C@ ( r op )
|
||||
OR A,
|
||||
;
|
||||
0x10 OProt RLr,
|
||||
0x00 OProt RLCr,
|
||||
0x18 OProt RRr,
|
||||
0x08 OProt RRCr,
|
||||
0x20 OProt SLAr,
|
||||
0x38 OProt SRLr,
|
||||
0x10 OProt RL,
|
||||
0x00 OProt RLC,
|
||||
0x18 OProt RR,
|
||||
0x08 OProt RRC,
|
||||
0x20 OProt SLA,
|
||||
0x38 OProt SRL,
|
||||
|
11
blk/236
11
blk/236
@ -1,11 +1,10 @@
|
||||
( ss -- )
|
||||
: OP2ss
|
||||
: OP2d ( d -- )
|
||||
CREATE C,
|
||||
DOES>
|
||||
0xed A,
|
||||
C@ SWAP ( op ss )
|
||||
<<4 ( op ss<< 4 )
|
||||
C@ SWAP ( op d )
|
||||
<<4 ( op d<< 4 )
|
||||
OR A,
|
||||
;
|
||||
0x4a OP2ss ADCHLss,
|
||||
0x42 OP2ss SBCHLss,
|
||||
0x4a OP2d ADCHLd,
|
||||
0x42 OP2d SBCHLd,
|
||||
|
12
blk/238
12
blk/238
@ -1,11 +1,11 @@
|
||||
( dd nn -- )
|
||||
: OP3ddnn
|
||||
( d n -- )
|
||||
: OP3dn
|
||||
CREATE C,
|
||||
DOES>
|
||||
C@ ( dd nn op )
|
||||
ROT ( nn op dd )
|
||||
<<4 ( nn op dd<<4 )
|
||||
C@ ( d n op )
|
||||
ROT ( n op d )
|
||||
<<4 ( n op d<<4 )
|
||||
OR A,
|
||||
A,,
|
||||
;
|
||||
0x01 OP3ddnn LDddnn,
|
||||
0x01 OP3dn LDdn,
|
||||
|
12
blk/240
12
blk/240
@ -1,11 +1,11 @@
|
||||
( nn -- )
|
||||
: OP3nn
|
||||
( n -- )
|
||||
: OP3n
|
||||
CREATE C,
|
||||
DOES>
|
||||
C@ A,
|
||||
A,,
|
||||
;
|
||||
0xcd OP3nn CALLnn,
|
||||
0xc3 OP3nn JPnn,
|
||||
0x22 OP3nn LD(nn)HL,
|
||||
0x2a OP3nn LDHL(nn),
|
||||
0xcd OP3n CALL,
|
||||
0xc3 OP3n JP,
|
||||
0x22 OP3n LD(n)HL,
|
||||
0x2a OP3n LDHL(n),
|
||||
|
6
blk/242
6
blk/242
@ -1,14 +1,14 @@
|
||||
: LDdd(nn), ( dd nn -- )
|
||||
: LDdd(n), ( d n -- )
|
||||
0xed A,
|
||||
SWAP <<4 0x4b OR A,
|
||||
A,,
|
||||
;
|
||||
: LD(nn)dd, ( nn dd -- )
|
||||
: LD(n)d, ( n d -- )
|
||||
0xed A,
|
||||
<<4 0x43 OR A,
|
||||
A,,
|
||||
;
|
||||
: RSTn, 0xc7 OR A, ;
|
||||
: RST, 0xc7 OR A, ;
|
||||
|
||||
: JP(IX), IX DROP JP(HL), ;
|
||||
: JP(IY), IY DROP JP(HL), ;
|
||||
|
12
blk/243
12
blk/243
@ -1,12 +1,12 @@
|
||||
: JPccnn, SWAP <<3 0xc2 OR A, A,, ;
|
||||
: BCALL, BIN( @ + CALLnn, ;
|
||||
: BJP, BIN( @ + JPnn, ;
|
||||
: BJPcc, BIN( @ + JPccnn, ;
|
||||
: JPc, SWAP <<3 0xc2 OR A, A,, ;
|
||||
: BCALL, BIN( @ + CALL, ;
|
||||
: BJP, BIN( @ + JP, ;
|
||||
: BJPc, BIN( @ + JPc, ;
|
||||
|
||||
VARIABLE lblchkPS
|
||||
: chkPS, lblchkPS @ CALLnn, ; ( chkPS, B305 )
|
||||
: chkPS, lblchkPS @ CALL, ; ( chkPS, B305 )
|
||||
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 )
|
||||
(entry) 0 C, ( 0 == native ) ;
|
||||
: ;CODE JPNEXT, ;
|
||||
|
16
blk/249
16
blk/249
@ -1,12 +1,12 @@
|
||||
( Macros )
|
||||
( clear carry + SBC )
|
||||
: SUBHLss, A ORr, SBCHLss, ;
|
||||
: PUSH0, BC 0 LDddnn, BC PUSHqq, ;
|
||||
: PUSH1, BC 1 LDddnn, BC PUSHqq, ;
|
||||
: PUSHZ, BC 0 LDddnn, IFZ, BC INCss, THEN, BC PUSHqq, ;
|
||||
: PUSHA, B 0 LDrn, C A LDrr, BC PUSHqq, ;
|
||||
: SUBHLd, A ORr, SBCHLd, ;
|
||||
: PUSH0, BC 0 LDdn, BC PUSH, ;
|
||||
: PUSH1, BC 1 LDdn, BC PUSH, ;
|
||||
: PUSHZ, BC 0 LDdn, IFZ, BC INCd, THEN, BC PUSH, ;
|
||||
: PUSHA, B 0 LDri, C A LDrr, BC PUSH, ;
|
||||
: HLZ, A H LDrr, L ORr, ;
|
||||
: DEZ, A D LDrr, E ORr, ;
|
||||
: LDDE(HL), E (HL) LDrr, HL INCss, D (HL) LDrr, ;
|
||||
: OUTHL, DUP A H LDrr, OUTnA, A L LDrr, OUTnA, ;
|
||||
: OUTDE, DUP A D LDrr, OUTnA, A E LDrr, OUTnA, ;
|
||||
: LDDE(HL), E (HL) LDrr, HL INCd, D (HL) LDrr, ;
|
||||
: OUTHL, DUP A H LDrr, OUTiA, A L LDrr, OUTiA, ;
|
||||
: OUTDE, DUP A D LDrr, OUTiA, A E LDrr, OUTiA, ;
|
||||
|
12
blk/283
12
blk/283
@ -1,14 +1,14 @@
|
||||
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, 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 )
|
||||
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 )
|
||||
0 JPnn, ( RST 28 )
|
||||
0 JP, ( RST 28 )
|
||||
NOP, NOP, NOP, NOP, NOP, ( unused )
|
||||
0 JPnn, ( RST 30 )
|
||||
0 JP, ( RST 30 )
|
||||
NOP, NOP, NOP, NOP, NOP, ( unused )
|
||||
0 JPnn, ( RST 38 )
|
||||
0 JP, ( RST 38 )
|
||||
|
4
blk/284
4
blk/284
@ -7,10 +7,10 @@
|
||||
H@ XCURRENT ! ( set current tip of dict, 0x42 )
|
||||
0 A, ( native )
|
||||
0x14 BCALL, ( popRS )
|
||||
HL PUSHqq, IY POPqq, ( --> IP )
|
||||
HL PUSH, IY POP, ( --> IP )
|
||||
JPNEXT,
|
||||
CODE (br) ( 0x53 )
|
||||
L2 BSET ( used in CBR )
|
||||
E 0 IY+ LDrIXY, D 1 IY+ LDrIXY,
|
||||
DE ADDIYss,
|
||||
DE ADDIYd,
|
||||
JPNEXT,
|
||||
|
6
blk/285
6
blk/285
@ -1,10 +1,10 @@
|
||||
CODE (?br) ( 0x67 )
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
HLZ,
|
||||
JRZ, L2 BWR ( br + 1. False, branch )
|
||||
L1 BSET ( loop will jump here )
|
||||
( True, skip next 2 bytes and don't branch )
|
||||
IY INCss, IY INCss,
|
||||
IY INCd, IY INCd,
|
||||
JPNEXT, NOP, NOP, NOP,
|
||||
CODE (loop) ( 0x80 )
|
||||
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 1 IX+ LDrIXY, 1 IX- CP(IXY+), JRNZ, L2 BWR ( 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
|
||||
|
7
blk/286
7
blk/286
@ -1,5 +1,5 @@
|
||||
CODE 2>R ( 0xa9 )
|
||||
DE POPqq, HL POPqq,
|
||||
DE POP, HL POP,
|
||||
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
|
||||
;CODE NOP, NOP, NOP,
|
||||
CODE (n) ( 0xbf, number literal )
|
||||
@ -8,7 +8,6 @@ CODE (n) ( 0xbf, number literal )
|
||||
Read, push, then advance IP. )
|
||||
E 0 IY+ LDrIXY,
|
||||
D 1 IY+ LDrIXY,
|
||||
IY INCss,
|
||||
IY INCss,
|
||||
DE PUSHqq,
|
||||
IY INCd, IY INCd,
|
||||
DE PUSH,
|
||||
;CODE
|
||||
|
10
blk/287
10
blk/287
@ -2,10 +2,10 @@ CODE (s) ( 0xd4, string literal )
|
||||
( Like (n) but instead of being followed by a 2 bytes
|
||||
number, it's followed by a string. When called, puts the
|
||||
string's address on PS )
|
||||
IY PUSHqq, HL POPqq, ( <-- IP )
|
||||
E (HL) LDrr, D 0 LDrn,
|
||||
DE INCss,
|
||||
DE ADDIYss,
|
||||
HL PUSHqq,
|
||||
IY PUSH, HL POP, ( <-- IP )
|
||||
E (HL) LDrr, D 0 LDri,
|
||||
DE INCd,
|
||||
DE ADDIYd,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
( END OF STABLE ABI )
|
||||
|
6
blk/288
6
blk/288
@ -1,12 +1,12 @@
|
||||
CODE >R
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
17 BCALL, ( 17 == pushRS )
|
||||
;CODE
|
||||
CODE R>
|
||||
20 BCALL, ( 20 == popRS )
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
CODE 2R>
|
||||
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
|
||||
HL PUSHqq, DE PUSHqq,
|
||||
HL PUSH, DE PUSH,
|
||||
;CODE
|
||||
|
6
blk/291
6
blk/291
@ -2,7 +2,7 @@ lblfind BSET
|
||||
( Find the entry corresponding to word name where (HL) points
|
||||
to in dictionary having its tip at DE and sets DE to point
|
||||
to that entry. Z if found, NZ if not. )
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
( First, figure out string len )
|
||||
A (HL) LDrr, A ORr,
|
||||
( 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*.
|
||||
Because of our dict structure and because we know our
|
||||
lengths, it's easier to compare starting from the end. )
|
||||
C A LDrr, B 0 LDrn, ( C holds our length )
|
||||
BC ADDHLss, HL INCss, ( HL points to after-last-char )
|
||||
C A LDrr, B 0 LDri, ( C holds our length )
|
||||
BC ADDHLd, HL INCd, ( HL points to after-last-char )
|
||||
( cont . )
|
||||
|
8
blk/292
8
blk/292
@ -1,8 +1,8 @@
|
||||
BEGIN, ( inner )
|
||||
( DE is a wordref, first step, do our len correspond? )
|
||||
HL PUSHqq, ( --> lvl 1 )
|
||||
DE PUSHqq, ( --> lvl 2 )
|
||||
DE DECss,
|
||||
HL PUSH, ( --> lvl 1 )
|
||||
DE PUSH, ( --> lvl 2 )
|
||||
DE DECd,
|
||||
LDA(DE),
|
||||
0x7f ANDn, ( remove IMMEDIATE flag )
|
||||
0x7f ANDi, ( remove IMMEDIATE flag )
|
||||
C CPr, ( cont. )
|
||||
|
8
blk/293
8
blk/293
@ -1,12 +1,12 @@
|
||||
IFZ,
|
||||
( match, let's compare the string then )
|
||||
DE DECss, ( Skip prev field. One less because we )
|
||||
DE DECss, ( pre-decrement )
|
||||
DE DECd, ( Skip prev field. One less because we )
|
||||
DE DECd, ( pre-decrement )
|
||||
B C LDrr, ( loop C times )
|
||||
BEGIN,
|
||||
( pre-decrement for easier Z matching )
|
||||
DE DECss,
|
||||
HL DECss,
|
||||
DE DECd,
|
||||
HL DECd,
|
||||
LDA(DE),
|
||||
(HL) CPr,
|
||||
JRNZ, BREAK,
|
||||
|
14
blk/294
14
blk/294
@ -1,16 +1,16 @@
|
||||
( At this point, Z is set if we have a match. In all cases,
|
||||
we want to pop HL and DE )
|
||||
DE POPqq, ( <-- lvl 2 )
|
||||
HL POPqq, ( <-- lvl 1 )
|
||||
DE POP, ( <-- lvl 2 )
|
||||
HL POP, ( <-- lvl 1 )
|
||||
JRZ, L2 FWR ( end-B296, match? we're done! )
|
||||
( no match, go to prev and continue )
|
||||
HL PUSHqq, ( --> lvl 1 )
|
||||
DE DECss,
|
||||
DE DECss,
|
||||
DE DECss, ( prev field )
|
||||
DE PUSHqq, ( --> lvl 2 )
|
||||
HL PUSH, ( --> lvl 1 )
|
||||
DE DECd, DE DECd, DE DECd, ( prev field )
|
||||
DE PUSH, ( --> lvl 2 )
|
||||
EXDEHL,
|
||||
LDDE(HL),
|
||||
|
||||
|
||||
|
||||
|
||||
( cont. )
|
||||
|
6
blk/295
6
blk/295
@ -1,14 +1,14 @@
|
||||
( DE contains prev offset )
|
||||
HL POPqq, ( <-- lvl 2 )
|
||||
HL POP, ( <-- lvl 2 )
|
||||
( HL is prev field's addr. Is offset zero? )
|
||||
DEZ,
|
||||
IFNZ,
|
||||
( get absolute addr from offset )
|
||||
( carry cleared from "or e" )
|
||||
DE SBCHLss,
|
||||
DE SBCHLd,
|
||||
EXDEHL, ( result in DE )
|
||||
THEN,
|
||||
HL POPqq, ( <-- lvl 1 )
|
||||
HL POP, ( <-- lvl 1 )
|
||||
JRNZ, AGAIN, ( inner-B292, try to match again )
|
||||
( Z set? end of dict, unset Z )
|
||||
|
||||
|
6
blk/297
6
blk/297
@ -1,6 +1,5 @@
|
||||
lblpushRS BSET PC ORG @ 0x12 + ! ( pushRS )
|
||||
IX INCss,
|
||||
IX INCss,
|
||||
IX INCd, IX INCd,
|
||||
0 IX+ L LDIXYr,
|
||||
1 IX+ H LDIXYr,
|
||||
RET,
|
||||
@ -8,6 +7,5 @@ lblpushRS BSET PC ORG @ 0x12 + ! ( pushRS )
|
||||
PC ORG @ 0x15 + ! ( popRS )
|
||||
L 0 IX+ LDrIXY,
|
||||
H 1 IX+ LDrIXY,
|
||||
IX DECss,
|
||||
IX DECss,
|
||||
IX DECd, IX DECd,
|
||||
RET,
|
||||
|
2
blk/298
2
blk/298
@ -1,3 +1,3 @@
|
||||
lblofl BSET ( abortUnderflow )
|
||||
DE BIN( @ 0x06 ( uflw ) + LDdd(nn),
|
||||
DE BIN( @ 0x06 ( uflw ) + LDdd(n),
|
||||
JR, L2 FWR ( execute, B301 )
|
||||
|
12
blk/299
12
blk/299
@ -1,13 +1,13 @@
|
||||
PC ORG @ 1 + ! ( main )
|
||||
( 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 )
|
||||
HL RAMSTART 0x80 + LDddnn,
|
||||
RAMSTART 0x04 + LD(nn)HL, ( RAM+04 == HERE )
|
||||
HL RAMSTART 0x80 + LDdn,
|
||||
RAMSTART 0x04 + LD(n)HL, ( RAM+04 == HERE )
|
||||
( LATEST is a label to the latest entry of the dict. It is
|
||||
written at offset 0x08 by the process or person building
|
||||
Forth. )
|
||||
BIN( @ 0x08 + LDHL(nn),
|
||||
RAMSTART 0x02 ( CURRENT ) + LD(nn)HL,
|
||||
DE BIN( @ 0x04 ( BOOT ) + LDdd(nn),
|
||||
BIN( @ 0x08 + LDHL(n),
|
||||
RAMSTART 0x02 ( CURRENT ) + LD(n)HL,
|
||||
DE BIN( @ 0x04 ( BOOT ) + LDdd(n),
|
||||
JR, L1 FWR ( execute, B301 )
|
||||
|
12
blk/300
12
blk/300
@ -3,14 +3,14 @@ lblnext BSET PC ORG @ 0x1b + ! ( next )
|
||||
we jump to current IP, but we also take care of increasing
|
||||
it by 2 before jumping. )
|
||||
( Before we continue: are stacks within bounds? )
|
||||
( PS ) HL PS_ADDR LDddnn,
|
||||
SP SUBHLss,
|
||||
( PS ) HL PS_ADDR LDdn,
|
||||
SP SUBHLd,
|
||||
JRC, lblofl BWR ( abortUnderflow-B298 )
|
||||
( RS ) IX PUSHqq, HL POPqq,
|
||||
DE RS_ADDR LDddnn,
|
||||
DE SUBHLss,
|
||||
( RS ) IX PUSH, HL POP,
|
||||
DE RS_ADDR LDdn,
|
||||
DE SUBHLd,
|
||||
JRC, lblofl BWR ( IX < RS_ADDR? abortUnderflow-B298 )
|
||||
E 0 IY+ LDrIXY,
|
||||
D 1 IY+ LDrIXY,
|
||||
IY INCss, IY INCss,
|
||||
IY INCd, IY INCd,
|
||||
( continue to execute )
|
||||
|
6
blk/301
6
blk/301
@ -3,11 +3,11 @@ lblexec BSET L1 FSET ( B299 ) L2 FSET ( B298 )
|
||||
( We don't apply BIN( reliably on stable ABI stuff, we
|
||||
might need to adjust addr. Ugly, but well... )
|
||||
BIN( @ [IF]
|
||||
A XORr, D ORr, IFZ, D BIN( @ 256 / LDrn, THEN,
|
||||
A XORr, D ORr, IFZ, D BIN( @ 256 / LDri, THEN,
|
||||
[THEN]
|
||||
LDA(DE), DE INCss,
|
||||
LDA(DE), DE INCd,
|
||||
A ORr, IFZ, EXDEHL, JP(HL), THEN,
|
||||
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 )
|
||||
( continue to does, B302 )
|
||||
|
5
blk/302
5
blk/302
@ -5,9 +5,8 @@
|
||||
linkfrom the PFA, and then continue as a regular
|
||||
compiledWord. )
|
||||
EXDEHL,
|
||||
HL INCss,
|
||||
HL INCss,
|
||||
HL INCd, HL INCd,
|
||||
E (HL) LDrr,
|
||||
HL INCss,
|
||||
HL INCd,
|
||||
D (HL) LDrr,
|
||||
( continue to compiledWord )
|
||||
|
8
blk/303
8
blk/303
@ -2,11 +2,11 @@
|
||||
( 1. Push current IP to RS
|
||||
2. Set new IP to the second atom of the list
|
||||
3. Execute the first atom of the list. )
|
||||
IY PUSHqq, HL POPqq, ( <-- IP )
|
||||
lblpushRS @ ( pushRS ) CALLnn,
|
||||
IY PUSH, HL POP, ( <-- IP )
|
||||
lblpushRS @ ( pushRS ) CALL,
|
||||
EXDEHL, ( HL points to PFA )
|
||||
( While we inc, dereference into DE for execute call later. )
|
||||
LDDE(HL),
|
||||
HL INCss,
|
||||
HL PUSHqq, IY POPqq, ( --> IP )
|
||||
HL INCd,
|
||||
HL PUSH, IY POP, ( --> IP )
|
||||
JR, lblexec BWR ( execute-B301 )
|
||||
|
6
blk/305
6
blk/305
@ -5,8 +5,8 @@ lblchkPS BSET ( chkPS )
|
||||
EXX,
|
||||
( We have the return address for this very call on the stack
|
||||
and protected registers. 2- is to compensate that. )
|
||||
HL PS_ADDR 2 - LDddnn,
|
||||
SP SUBHLss,
|
||||
HL PS_ADDR 2- LDdn,
|
||||
SP SUBHLd,
|
||||
EXX,
|
||||
CNC RETcc, ( PS_ADDR >= SP? good )
|
||||
CNC RETc, ( PS_ADDR >= SP? good )
|
||||
JR, lblofl BWR ( abortUnderflow-B298 )
|
||||
|
9
blk/306
9
blk/306
@ -3,13 +3,12 @@
|
||||
expected to be defined in platform-specific code. )
|
||||
|
||||
CODE EXECUTE
|
||||
DE POPqq,
|
||||
DE POP,
|
||||
chkPS,
|
||||
JR, lblexec BWR ( execute-B301 )
|
||||
|
||||
( a b c -- b c a )
|
||||
CODE ROT
|
||||
HL POPqq, ( C ) DE POPqq, ( B ) BC POPqq, ( A )
|
||||
CODE ROT ( a b c -- b c a )
|
||||
HL POP, ( C ) DE POP, ( B ) BC POP, ( A )
|
||||
chkPS,
|
||||
DE PUSHqq, ( B ) HL PUSHqq, ( C ) BC PUSHqq, ( A )
|
||||
DE PUSH, ( B ) HL PUSH, ( C ) BC PUSH, ( A )
|
||||
;CODE
|
||||
|
18
blk/307
18
blk/307
@ -1,16 +1,14 @@
|
||||
( a -- a a )
|
||||
CODE DUP
|
||||
HL POPqq, chkPS,
|
||||
HL PUSHqq, HL PUSHqq,
|
||||
CODE DUP ( a -- a a )
|
||||
HL POP, chkPS,
|
||||
HL PUSH, HL PUSH,
|
||||
;CODE
|
||||
|
||||
CODE ?DUP
|
||||
HL POPqq, chkPS,
|
||||
HL PUSHqq,
|
||||
HLZ, IFNZ, HL PUSHqq, THEN,
|
||||
HL POP, chkPS,
|
||||
HL PUSH,
|
||||
HLZ, IFNZ, HL PUSH, THEN,
|
||||
;CODE
|
||||
|
||||
( a -- )
|
||||
CODE DROP
|
||||
HL POPqq,
|
||||
CODE DROP ( a -- )
|
||||
HL POP,
|
||||
;CODE
|
||||
|
8
blk/308
8
blk/308
@ -1,8 +1,8 @@
|
||||
( a b -- b a )
|
||||
CODE SWAP
|
||||
HL POPqq, ( B )
|
||||
DE POPqq, ( A )
|
||||
HL POP, ( B )
|
||||
DE POP, ( A )
|
||||
chkPS,
|
||||
HL PUSHqq, ( B )
|
||||
DE PUSHqq, ( A )
|
||||
HL PUSH, ( B )
|
||||
DE PUSH, ( A )
|
||||
;CODE
|
||||
|
10
blk/309
10
blk/309
@ -1,9 +1,9 @@
|
||||
( a b -- a b a )
|
||||
CODE OVER
|
||||
HL POPqq, ( B )
|
||||
DE POPqq, ( A )
|
||||
HL POP, ( B )
|
||||
DE POP, ( A )
|
||||
chkPS,
|
||||
DE PUSHqq, ( A )
|
||||
HL PUSHqq, ( B )
|
||||
DE PUSHqq, ( A )
|
||||
DE PUSH, ( A )
|
||||
HL PUSH, ( B )
|
||||
DE PUSH, ( A )
|
||||
;CODE
|
||||
|
16
blk/310
16
blk/310
@ -1,15 +1,15 @@
|
||||
CODE PICK
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
( x2 )
|
||||
L SLAr, H RLr,
|
||||
SP ADDHLss,
|
||||
L SLA, H RL,
|
||||
SP ADDHLd,
|
||||
C (HL) LDrr,
|
||||
HL INCss,
|
||||
HL INCd,
|
||||
B (HL) LDrr,
|
||||
( check PS range before returning )
|
||||
EXDEHL,
|
||||
HL PS_ADDR LDddnn,
|
||||
DE SUBHLss,
|
||||
CC lblofl @ JPccnn, ( abortUnderflow-B298 )
|
||||
BC PUSHqq,
|
||||
HL PS_ADDR LDdn,
|
||||
DE SUBHLd,
|
||||
CC lblofl @ JPc, ( abortUnderflow-B298 )
|
||||
BC PUSH,
|
||||
;CODE
|
||||
|
10
blk/311
10
blk/311
@ -2,14 +2,14 @@
|
||||
"1 2 3 4 4 (roll)" --> "1 3 4 4". No sanity checks, never
|
||||
call with 0. )
|
||||
CODE (roll)
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
B H LDrr,
|
||||
C L LDrr,
|
||||
SP ADDHLss,
|
||||
HL INCss,
|
||||
SP ADDHLd,
|
||||
HL INCd,
|
||||
D H LDrr,
|
||||
E L LDrr,
|
||||
HL DECss,
|
||||
HL DECss,
|
||||
HL DECd,
|
||||
HL DECd,
|
||||
LDDR,
|
||||
;CODE
|
||||
|
15
blk/312
15
blk/312
@ -1,13 +1,10 @@
|
||||
( a b -- )
|
||||
CODE 2DROP
|
||||
HL POPqq,
|
||||
HL POPqq,
|
||||
CODE 2DROP ( a b -- )
|
||||
HL POP, HL POP,
|
||||
;CODE
|
||||
|
||||
( a b -- a b a b )
|
||||
CODE 2DUP
|
||||
HL POPqq, ( b ) DE POPqq, ( a )
|
||||
CODE 2DUP ( a b -- a b a b )
|
||||
HL POP, ( b ) DE POP, ( a )
|
||||
chkPS,
|
||||
DE PUSHqq, HL PUSHqq,
|
||||
DE PUSHqq, HL PUSHqq,
|
||||
DE PUSH, HL PUSH,
|
||||
DE PUSH, HL PUSH,
|
||||
;CODE
|
||||
|
10
blk/313
10
blk/313
@ -1,10 +1,10 @@
|
||||
CODE S0
|
||||
HL PS_ADDR LDddnn,
|
||||
HL PUSHqq,
|
||||
HL PS_ADDR LDdn,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
||||
CODE 'S
|
||||
HL 0 LDddnn,
|
||||
SP ADDHLss,
|
||||
HL PUSHqq,
|
||||
HL 0 LDdn,
|
||||
SP ADDHLd,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
6
blk/314
6
blk/314
@ -1,6 +1,6 @@
|
||||
CODE AND
|
||||
HL POPqq,
|
||||
DE POPqq,
|
||||
HL POP,
|
||||
DE POP,
|
||||
chkPS,
|
||||
A E LDrr,
|
||||
L ANDr,
|
||||
@ -8,5 +8,5 @@ CODE AND
|
||||
A D LDrr,
|
||||
H ANDr,
|
||||
H A LDrr,
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
6
blk/315
6
blk/315
@ -1,6 +1,6 @@
|
||||
CODE OR
|
||||
HL POPqq,
|
||||
DE POPqq,
|
||||
HL POP,
|
||||
DE POP,
|
||||
chkPS,
|
||||
A E LDrr,
|
||||
L ORr,
|
||||
@ -8,5 +8,5 @@ CODE OR
|
||||
A D LDrr,
|
||||
H ORr,
|
||||
H A LDrr,
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
6
blk/316
6
blk/316
@ -1,6 +1,6 @@
|
||||
CODE XOR
|
||||
HL POPqq,
|
||||
DE POPqq,
|
||||
HL POP,
|
||||
DE POP,
|
||||
chkPS,
|
||||
A E LDrr,
|
||||
L XORr,
|
||||
@ -8,5 +8,5 @@ CODE XOR
|
||||
A D LDrr,
|
||||
H XORr,
|
||||
H A LDrr,
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
16
blk/318
16
blk/318
@ -1,15 +1,15 @@
|
||||
CODE +
|
||||
HL POPqq,
|
||||
DE POPqq,
|
||||
HL POP,
|
||||
DE POP,
|
||||
chkPS,
|
||||
DE ADDHLss,
|
||||
HL PUSHqq,
|
||||
DE ADDHLd,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
||||
CODE -
|
||||
DE POPqq,
|
||||
HL POPqq,
|
||||
DE POP,
|
||||
HL POP,
|
||||
chkPS,
|
||||
DE SUBHLss,
|
||||
HL PUSHqq,
|
||||
DE SUBHLd,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
16
blk/319
16
blk/319
@ -1,16 +1,16 @@
|
||||
CODE * ( DE * BC -> DE (high) and HL (low) )
|
||||
DE POPqq, BC POPqq, chkPS,
|
||||
HL 0 LDddnn,
|
||||
A 0x10 LDrn,
|
||||
DE POP, BC POP, chkPS,
|
||||
HL 0 LDdn,
|
||||
A 0x10 LDri,
|
||||
( loop )
|
||||
HL ADDHLss,
|
||||
E RLr, D RLr,
|
||||
HL ADDHLd,
|
||||
E RL, D RL,
|
||||
JRNC, 4 A, ( noinc )
|
||||
BC ADDHLss,
|
||||
BC ADDHLd,
|
||||
JRNC, 1 A, ( noinc )
|
||||
DE INCss,
|
||||
DE INCd,
|
||||
( noinc )
|
||||
A DECr,
|
||||
JRNZ, -14 A, ( loop )
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
8
blk/320
8
blk/320
@ -2,12 +2,12 @@
|
||||
( Divides AC by DE and places the quotient in AC and the
|
||||
remainder in HL )
|
||||
CODE /MOD
|
||||
DE POPqq,
|
||||
BC POPqq,
|
||||
DE POP,
|
||||
BC POP,
|
||||
chkPS,
|
||||
A B LDrr,
|
||||
B 16 LDrn,
|
||||
HL 0 LDddnn,
|
||||
B 16 LDri,
|
||||
HL 0 LDdn,
|
||||
|
||||
|
||||
|
||||
|
12
blk/321
12
blk/321
@ -1,15 +1,15 @@
|
||||
BEGIN, ( loop )
|
||||
SCF,
|
||||
C RLr,
|
||||
C RL,
|
||||
RLA,
|
||||
HL ADCHLss,
|
||||
DE SBCHLss,
|
||||
HL ADCHLd,
|
||||
DE SBCHLd,
|
||||
IFC,
|
||||
DE ADDHLss,
|
||||
DE ADDHLd,
|
||||
C DECr,
|
||||
THEN,
|
||||
DJNZ, AGAIN, ( loop )
|
||||
B A LDrr,
|
||||
HL PUSHqq,
|
||||
BC PUSHqq,
|
||||
HL PUSH,
|
||||
BC PUSH,
|
||||
;CODE
|
||||
|
12
blk/322
12
blk/322
@ -1,15 +1,15 @@
|
||||
CODE !
|
||||
HL POPqq,
|
||||
DE POPqq,
|
||||
HL POP,
|
||||
DE POP,
|
||||
(HL) E LDrr,
|
||||
HL INCss,
|
||||
HL INCd,
|
||||
(HL) D LDrr,
|
||||
;CODE
|
||||
CODE @
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
chkPS,
|
||||
E (HL) LDrr,
|
||||
HL INCss,
|
||||
HL INCd,
|
||||
D (HL) LDrr,
|
||||
DE PUSHqq,
|
||||
DE PUSH,
|
||||
;CODE
|
||||
|
10
blk/323
10
blk/323
@ -1,13 +1,13 @@
|
||||
CODE C!
|
||||
HL POPqq,
|
||||
DE POPqq,
|
||||
HL POP,
|
||||
DE POP,
|
||||
(HL) E LDrr,
|
||||
;CODE
|
||||
|
||||
CODE C@
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
chkPS,
|
||||
L (HL) LDrr,
|
||||
H 0 LDrn,
|
||||
HL PUSHqq,
|
||||
H 0 LDri,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
10
blk/324
10
blk/324
@ -1,13 +1,13 @@
|
||||
CODE PC!
|
||||
BC POPqq,
|
||||
HL POPqq,
|
||||
BC POP,
|
||||
HL POP,
|
||||
L OUT(C)r,
|
||||
;CODE
|
||||
|
||||
CODE PC@
|
||||
BC POPqq,
|
||||
BC POP,
|
||||
chkPS,
|
||||
H 0 LDrn,
|
||||
H 0 LDri,
|
||||
L INr(C),
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
6
blk/325
6
blk/325
@ -1,15 +1,15 @@
|
||||
CODE I
|
||||
L 0 IX+ LDrIXY,
|
||||
H 1 IX+ LDrIXY,
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
CODE I'
|
||||
L 2 IX- LDrIXY,
|
||||
H 1 IX- LDrIXY,
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
CODE J
|
||||
L 4 IX- LDrIXY,
|
||||
H 3 IX- LDrIXY,
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
4
blk/327
4
blk/327
@ -3,9 +3,9 @@ CODE BYE
|
||||
;CODE
|
||||
|
||||
CODE (resSP)
|
||||
SP PS_ADDR LDddnn,
|
||||
SP PS_ADDR LDdn,
|
||||
;CODE
|
||||
|
||||
CODE (resRS)
|
||||
IX RS_ADDR LDddnn,
|
||||
IX RS_ADDR LDdn,
|
||||
;CODE
|
||||
|
4
blk/328
4
blk/328
@ -1,11 +1,11 @@
|
||||
CODE S=
|
||||
DE POPqq, HL POPqq, chkPS,
|
||||
DE POP, HL POP, chkPS,
|
||||
LDA(DE),
|
||||
(HL) CPr,
|
||||
IFZ, ( same size? )
|
||||
B A LDrr, ( loop A times )
|
||||
BEGIN,
|
||||
HL INCss, DE INCss,
|
||||
HL INCd, DE INCd,
|
||||
LDA(DE),
|
||||
(HL) CPr,
|
||||
JRNZ, BREAK, ( not equal? break early. NZ is set. )
|
||||
|
16
blk/329
16
blk/329
@ -1,15 +1,15 @@
|
||||
CODE CMP
|
||||
HL POPqq,
|
||||
DE POPqq,
|
||||
HL POP,
|
||||
DE POP,
|
||||
chkPS,
|
||||
DE SUBHLss,
|
||||
BC 0 LDddnn,
|
||||
DE SUBHLd,
|
||||
BC 0 LDdn,
|
||||
IFNZ, ( < or > )
|
||||
BC INCss,
|
||||
BC INCd,
|
||||
IFNC, ( < )
|
||||
BC DECss,
|
||||
BC DECss,
|
||||
BC DECd,
|
||||
BC DECd,
|
||||
THEN,
|
||||
THEN,
|
||||
BC PUSHqq,
|
||||
BC PUSH,
|
||||
;CODE
|
||||
|
10
blk/330
10
blk/330
@ -1,15 +1,15 @@
|
||||
CODE _find ( cur w -- a f )
|
||||
HL POPqq, ( w )
|
||||
DE POPqq, ( cur )
|
||||
HL POP, ( w )
|
||||
DE POP, ( cur )
|
||||
chkPS,
|
||||
lblfind @ CALLnn,
|
||||
lblfind @ CALL,
|
||||
IFNZ,
|
||||
( not found )
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
PUSH0,
|
||||
JPNEXT,
|
||||
THEN,
|
||||
( found )
|
||||
DE PUSHqq,
|
||||
DE PUSH,
|
||||
PUSH1,
|
||||
;CODE
|
||||
|
4
blk/331
4
blk/331
@ -7,6 +7,6 @@ CODE 0 PUSH0, ;CODE
|
||||
CODE 1 PUSH1, ;CODE
|
||||
|
||||
CODE -1
|
||||
HL -1 LDddnn,
|
||||
HL PUSHqq,
|
||||
HL -1 LDdn,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
12
blk/332
12
blk/332
@ -1,13 +1,13 @@
|
||||
CODE 1+
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
chkPS,
|
||||
HL INCss,
|
||||
HL PUSHqq,
|
||||
HL INCd,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
||||
CODE 1-
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
chkPS,
|
||||
HL DECss,
|
||||
HL PUSHqq,
|
||||
HL DECd,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
16
blk/333
16
blk/333
@ -1,15 +1,15 @@
|
||||
CODE 2+
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
chkPS,
|
||||
HL INCss,
|
||||
HL INCss,
|
||||
HL PUSHqq,
|
||||
HL INCd,
|
||||
HL INCd,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
||||
CODE 2-
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
chkPS,
|
||||
HL DECss,
|
||||
HL DECss,
|
||||
HL PUSHqq,
|
||||
HL DECd,
|
||||
HL DECd,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
8
blk/334
8
blk/334
@ -1,12 +1,12 @@
|
||||
CODE RSHIFT ( n u -- n )
|
||||
BC POPqq, ( u )
|
||||
HL POPqq, ( n )
|
||||
BC POP, ( u )
|
||||
HL POP, ( n )
|
||||
chkPS,
|
||||
B C LDrr,
|
||||
B INCr, B DECr, IFNZ,
|
||||
BEGIN,
|
||||
H SRLr, L RRr,
|
||||
H SRL, L RR,
|
||||
DJNZ, AGAIN,
|
||||
THEN,
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
8
blk/335
8
blk/335
@ -1,12 +1,12 @@
|
||||
CODE LSHIFT ( n u -- n )
|
||||
BC POPqq, ( u )
|
||||
HL POPqq, ( n )
|
||||
BC POP, ( u )
|
||||
HL POP, ( n )
|
||||
chkPS,
|
||||
B C LDrr,
|
||||
B INCr, B DECr, IFNZ,
|
||||
BEGIN,
|
||||
L SLAr, H RLr,
|
||||
L SLA, H RL,
|
||||
DJNZ, AGAIN,
|
||||
THEN,
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
18
blk/493
18
blk/493
@ -1,16 +1,16 @@
|
||||
CODE (key)
|
||||
A 0x01 LDrn, ( @KEY )
|
||||
0x28 RSTn,
|
||||
A 0x01 LDri, ( @KEY )
|
||||
0x28 RST,
|
||||
PUSHA,
|
||||
;CODE
|
||||
CODE (emit)
|
||||
BC POPqq, ( c == @DSP arg ) chkPS,
|
||||
A 0x02 LDrn, ( @DSP )
|
||||
0x28 RSTn,
|
||||
BC POP, ( c == @DSP arg ) chkPS,
|
||||
A 0x02 LDri, ( @DSP )
|
||||
0x28 RST,
|
||||
;CODE
|
||||
CODE AT-XY
|
||||
DE POPqq, H E LDrr, ( Y )
|
||||
DE POPqq, L E LDrr, ( X ) chkPS,
|
||||
A 0x0f LDrn, ( @VDCTL ) B 3 LDrn, ( setcur )
|
||||
0x28 RSTn,
|
||||
DE POP, H E LDrr, ( Y )
|
||||
DE POP, L E LDrr, ( X ) chkPS,
|
||||
A 0x0f LDri, ( @VDCTL ) B 3 LDri, ( setcur )
|
||||
0x28 RST,
|
||||
;CODE
|
||||
|
12
blk/494
12
blk/494
@ -1,12 +1,12 @@
|
||||
: LINES 24 ; : COLS 80 ;
|
||||
CODE BYE
|
||||
HL 0 LDddnn,
|
||||
A 0x16 LDrn, ( @EXIT )
|
||||
0x28 RSTn,
|
||||
HL 0 LDdn,
|
||||
A 0x16 LDri, ( @EXIT )
|
||||
0x28 RST,
|
||||
CODE @DCSTAT ( drv -- f )
|
||||
BC POPqq,
|
||||
BC POP,
|
||||
chkPS,
|
||||
A 0x28 LDrn, ( @DCSTAT )
|
||||
0x28 RSTn,
|
||||
A 0x28 LDri, ( @DCSTAT )
|
||||
0x28 RST,
|
||||
PUSHZ,
|
||||
;CODE
|
||||
|
10
blk/495
10
blk/495
@ -1,9 +1,9 @@
|
||||
CODE @RDSEC ( drv cylsec addr -- f )
|
||||
HL POPqq,
|
||||
DE POPqq,
|
||||
BC POPqq,
|
||||
HL POP,
|
||||
DE POP,
|
||||
BC POP,
|
||||
chkPS,
|
||||
A 0x31 LDrn, ( @RDSEC )
|
||||
0x28 RSTn,
|
||||
A 0x31 LDri, ( @RDSEC )
|
||||
0x28 RST,
|
||||
PUSHZ,
|
||||
;CODE
|
||||
|
16
blk/496
16
blk/496
@ -1,16 +1,16 @@
|
||||
CODE @WRSEC ( drv cylsec addr -- f )
|
||||
HL POPqq,
|
||||
DE POPqq,
|
||||
BC POPqq,
|
||||
HL POP,
|
||||
DE POP,
|
||||
BC POP,
|
||||
chkPS,
|
||||
A 0x35 LDrn, ( @WRSEC )
|
||||
0x28 RSTn,
|
||||
A 0x35 LDri, ( @WRSEC )
|
||||
0x28 RST,
|
||||
PUSHZ,
|
||||
;CODE
|
||||
CODE @GET ( a -- c f )
|
||||
DE POPqq,
|
||||
DE POP,
|
||||
chkPS,
|
||||
A 0x03 LDrn, ( @GET )
|
||||
0x28 RSTn,
|
||||
A 0x03 LDri, ( @GET )
|
||||
0x28 RST,
|
||||
PUSHA, PUSHZ,
|
||||
;CODE
|
||||
|
8
blk/497
8
blk/497
@ -1,8 +1,8 @@
|
||||
CODE @PUT ( c a -- f )
|
||||
DE POPqq,
|
||||
BC POPqq,
|
||||
DE POP,
|
||||
BC POP,
|
||||
chkPS,
|
||||
A 0x04 LDrn, ( @PUT )
|
||||
0x28 RSTn,
|
||||
A 0x04 LDri, ( @PUT )
|
||||
0x28 RST,
|
||||
PUSHZ,
|
||||
;CODE
|
||||
|
14
blk/502
14
blk/502
@ -2,15 +2,15 @@
|
||||
(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. )
|
||||
: @GET,
|
||||
A 0x03 LDrn, ( @GET )
|
||||
DE COM_DRV_ADDR LDddnn,
|
||||
0x28 RSTn, JRNZ, L2 FWR ( maybeerror )
|
||||
A 0x03 LDri, ( @GET )
|
||||
DE COM_DRV_ADDR LDdn,
|
||||
0x28 RST, JRNZ, L2 FWR ( maybeerror )
|
||||
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 )
|
||||
C A LDrr,
|
||||
A 0x04 LDrn, ( @PUT )
|
||||
0x28 RSTn, JRNZ, L3 FWR ( error )
|
||||
A 0x04 LDri, ( @PUT )
|
||||
0x28 RST, JRNZ, L3 FWR ( error )
|
||||
A C LDrr, ;
|
||||
H@ ORG !
|
||||
HL DEST_ADDR LDddnn, ( cont. )
|
||||
HL DEST_ADDR LDdn, ( cont. )
|
||||
|
10
blk/503
10
blk/503
@ -1,15 +1,15 @@
|
||||
BEGIN,
|
||||
A 0xff LDrn, (HL) A LDrr, ( default mask )
|
||||
A 0xff LDri, (HL) A LDrr, ( default mask )
|
||||
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 )
|
||||
(HL) ANDr, (HL) A LDrr,
|
||||
HL INCss,
|
||||
HL INCd,
|
||||
JR, AGAIN,
|
||||
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? )
|
||||
A ORr, JRZ, L1 BWR ( loop2, not an error )
|
||||
L3 FSET ( error )
|
||||
C A LDrr, ( error code from @GET/@PUT )
|
||||
A 0x1a LDrn, ( @ERROR ) 0x28 RSTn, RET,
|
||||
A 0x1a LDri, ( @ERROR ) 0x28 RST, RET,
|
||||
|
2
blk/555
2
blk/555
@ -7,7 +7,7 @@
|
||||
we have to. )
|
||||
CODE _wait
|
||||
BEGIN,
|
||||
0x10 ( CMD ) INAn,
|
||||
0x10 ( CMD ) INAi,
|
||||
RLA, ( When 7th bit is clr, we can send a new cmd )
|
||||
JRC, AGAIN,
|
||||
;CODE
|
||||
|
12
blk/566
12
blk/566
@ -1,14 +1,14 @@
|
||||
( Requires KBD_MEM, KBD_PORT )
|
||||
( gm -- pm, get pressed keys mask for group mask gm )
|
||||
CODE _get
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
chkPS,
|
||||
DI,
|
||||
A 0xff LDrn,
|
||||
KBD_PORT OUTnA,
|
||||
A 0xff LDri,
|
||||
KBD_PORT OUTiA,
|
||||
A L LDrr,
|
||||
KBD_PORT OUTnA,
|
||||
KBD_PORT INAn,
|
||||
KBD_PORT OUTiA,
|
||||
KBD_PORT INAi,
|
||||
EI,
|
||||
L A LDrr, HL PUSHqq,
|
||||
L A LDrr, HL PUSH,
|
||||
;CODE
|
||||
|
16
blk/583
16
blk/583
@ -1,16 +1,14 @@
|
||||
(entry) ~ACIA ( Set RST 38 jump ) PC ORG @ 0x39 + !
|
||||
AF PUSHqq,
|
||||
HL PUSHqq,
|
||||
DE PUSHqq,
|
||||
AF PUSH, HL PUSH, DE PUSH,
|
||||
( Read our character from ACIA into our BUFIDX )
|
||||
ACIA_CTL INAn,
|
||||
0x01 ANDn, ( is ACIA rcv buf full? )
|
||||
ACIA_CTL INAi,
|
||||
0x01 ANDi, ( is ACIA rcv buf full? )
|
||||
IFNZ,
|
||||
( correct interrupt cause )
|
||||
( +2 == ACIAW> )
|
||||
ACIA_MEM 2+ LDHL(nn),
|
||||
ACIA_MEM 2+ LDHL(n),
|
||||
( is it == to ACIAR>? )
|
||||
( +0 == ACIAR> )
|
||||
DE ACIA_MEM LDdd(nn),
|
||||
( carry cleared from ANDn above )
|
||||
DE SBCHLss, ( cont. )
|
||||
DE ACIA_MEM LDdd(n),
|
||||
( carry cleared from ANDi above )
|
||||
DE SBCHLd, ( cont. )
|
||||
|
12
blk/584
12
blk/584
@ -1,16 +1,16 @@
|
||||
IFNZ, ( buffer full? )
|
||||
( no, continue )
|
||||
DE ADDHLss, ( restore ACIAW> )
|
||||
DE ADDHLd, ( restore ACIAW> )
|
||||
( buffer not full, let's write )
|
||||
ACIA_IO INAn,
|
||||
ACIA_IO INAi,
|
||||
(HL) A LDrr,
|
||||
( advance W> )
|
||||
HL INCss,
|
||||
HL INCd,
|
||||
( +2 == ACIAW> )
|
||||
ACIA_MEM 2+ LD(nn)HL,
|
||||
ACIA_MEM 2+ LD(n)HL,
|
||||
( +6 == ACIA) )
|
||||
DE ACIA_MEM 6 + LDdd(nn),
|
||||
DE SUBHLss,
|
||||
DE ACIA_MEM 6 + LDdd(n),
|
||||
DE SUBHLd,
|
||||
|
||||
|
||||
( cont. )
|
||||
|
11
blk/585
11
blk/585
@ -1,14 +1,11 @@
|
||||
IFZ, ( end of buffer reached? )
|
||||
( yes )
|
||||
( +4 == ACIA( )
|
||||
ACIA_MEM 4 + LDHL(nn),
|
||||
ACIA_MEM 4 + LDHL(n),
|
||||
( +2 == ACIAW> )
|
||||
ACIA_MEM 2+ LD(nn)HL,
|
||||
ACIA_MEM 2+ LD(n)HL,
|
||||
THEN,
|
||||
THEN,
|
||||
THEN,
|
||||
DE POPqq,
|
||||
HL POPqq,
|
||||
AF POPqq,
|
||||
EI,
|
||||
RETI,
|
||||
DE POP, HL POP, AF POP,
|
||||
EI, RETI,
|
||||
|
8
blk/602
8
blk/602
@ -1,12 +1,12 @@
|
||||
( Initiate SPI exchange with the SD card. n is the data to
|
||||
send. )
|
||||
CODE _sdcSR ( n -- n )
|
||||
HL POPqq,
|
||||
HL POP,
|
||||
chkPS,
|
||||
A L LDrr,
|
||||
SDC_SPI OUTnA,
|
||||
SDC_SPI OUTiA,
|
||||
NOP, NOP,
|
||||
SDC_SPI INAn,
|
||||
SDC_SPI INAi,
|
||||
L A LDrr,
|
||||
HL PUSHqq,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
16
blk/603
16
blk/603
@ -1,16 +1,16 @@
|
||||
CODE _sdcSel SDC_CSLOW OUTnA, ;CODE
|
||||
CODE _sdcDesel SDC_CSHIGH OUTnA, ;CODE
|
||||
CODE _sdcSel SDC_CSLOW OUTiA, ;CODE
|
||||
CODE _sdcDesel SDC_CSHIGH OUTiA, ;CODE
|
||||
( Computes n into crc c with polynomial 0x1021 )
|
||||
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,
|
||||
B 8 LDrn,
|
||||
B 8 LDri,
|
||||
BEGIN,
|
||||
E SLAr, D RLr,
|
||||
E SLA, D RL,
|
||||
IFC, ( msb is set, apply polynomial )
|
||||
A D LDrr, 0x10 XORn, D A LDrr,
|
||||
A E LDrr, 0x21 XORn, E A LDrr,
|
||||
A D LDrr, 0x10 XORi, D A LDrr,
|
||||
A E LDrr, 0x21 XORi, E A LDrr,
|
||||
THEN,
|
||||
DJNZ, AGAIN,
|
||||
DE PUSHqq,
|
||||
DE PUSH,
|
||||
;CODE
|
||||
|
10
blk/623
10
blk/623
@ -1,10 +1,10 @@
|
||||
: XYPOS [ VDP_MEM LITN ] ;
|
||||
CODE _ctl ( a -- sends LSB then MSB )
|
||||
HL POPqq, chkPS,
|
||||
A L LDrr, VDP_CTLPORT OUTnA,
|
||||
A H LDrr, VDP_CTLPORT OUTnA,
|
||||
HL POP, chkPS,
|
||||
A L LDrr, VDP_CTLPORT OUTiA,
|
||||
A H LDrr, VDP_CTLPORT OUTiA,
|
||||
;CODE
|
||||
CODE _data
|
||||
HL POPqq, chkPS,
|
||||
A L LDrr, VDP_DATAPORT OUTnA,
|
||||
HL POP, chkPS,
|
||||
A L LDrr, VDP_DATAPORT OUTiA,
|
||||
;CODE
|
||||
|
10
blk/624
10
blk/624
@ -1,9 +1,9 @@
|
||||
CODE _blank ( this is way too slow in Forth )
|
||||
A XORr, VDP_CTLPORT OUTnA,
|
||||
A 0x40 LDrn, VDP_CTLPORT OUTnA,
|
||||
HL 0x4000 LDddnn,
|
||||
A XORr, VDP_CTLPORT OUTiA,
|
||||
A 0x40 LDri, VDP_CTLPORT OUTiA,
|
||||
HL 0x4000 LDdn,
|
||||
BEGIN,
|
||||
A XORr, VDP_DATAPORT OUTnA,
|
||||
HL DECss, HLZ,
|
||||
A XORr, VDP_DATAPORT OUTiA,
|
||||
HL DECd, HLZ,
|
||||
JRNZ, AGAIN,
|
||||
;CODE
|
||||
|
18
blk/633
18
blk/633
@ -1,15 +1,15 @@
|
||||
CODE _status
|
||||
A 0b11111101 LDrn, ( TH output, unselected )
|
||||
PAD_CTLPORT OUTnA,
|
||||
PAD_D1PORT INAn,
|
||||
0x3f ANDn, ( low 6 bits are good )
|
||||
A 0b11111101 LDri, ( TH output, unselected )
|
||||
PAD_CTLPORT OUTiA,
|
||||
PAD_D1PORT INAi,
|
||||
0x3f ANDi, ( low 6 bits are good )
|
||||
B A LDrr, ( let's store them )
|
||||
( 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. )
|
||||
A 0b11011101 LDrn, ( TH output, selected )
|
||||
PAD_CTLPORT OUTnA,
|
||||
PAD_D1PORT INAn,
|
||||
0b00110000 ANDn,
|
||||
A SLAr, A SLAr, B ORr,
|
||||
A 0b11011101 LDri, ( TH output, selected )
|
||||
PAD_CTLPORT OUTiA,
|
||||
PAD_D1PORT INAi,
|
||||
0b00110000 ANDi,
|
||||
A SLA, A SLA, B ORr,
|
||||
PUSHA,
|
||||
;CODE
|
||||
|
Loading…
Reference in New Issue
Block a user