mirror of
https://github.com/forth-ev/VolksForth.git
synced 2024-11-22 20:34:07 +00:00
205 lines
13 KiB
Plaintext
205 lines
13 KiB
Plaintext
Screen 0 not modified
|
|
0 \ FORTH-6502 ASSEMBLER WFR ) cas 26jan06
|
|
1 ( BASIS: FORTH DIMENSIONS VOL III NO. 5)
|
|
2
|
|
3 Load from Screen 1 for the transient assembler:
|
|
4 This 6502 Forth Assembler can be loaded into the heap
|
|
5 and then not be saved in the final binary to save memory.
|
|
6
|
|
7 Load from Screen 2 for the regular assembler:
|
|
8 This 6502 Forth Assembler will be loaded into normal
|
|
9 memory and will be saved into the final binary.
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
Screen 1 not modified
|
|
0 \ TRANSIENT FORTH-6502 ASSEMBLER WFR ) er14dez88
|
|
1 ( BASIS: FORTH DIMENSIONS VOL III NO. 5)
|
|
2
|
|
3 ( INTERNAL LOADING 04MAY85BP/RE)
|
|
4 hex
|
|
5 \ HERE $200 HALLOT HEAP DP !
|
|
6 &10 LOAD
|
|
7 &11 LOAD
|
|
8 3 &8 THRU
|
|
9 &9 LOAD \ for System-Assembler
|
|
10
|
|
11 \ DP !
|
|
12
|
|
13 ONLYFORTH
|
|
14 decimal
|
|
15
|
|
Screen 2 not modified
|
|
0 \ FORTH-65 ASSEMBLER WFR ) er14dez88
|
|
1 ( BASIS: FORTH DIMENSIONS VOL III NO. 5)
|
|
2 ONLYFORTH
|
|
3 Vocabulary tassembler
|
|
4 TASSEMBLER ALSO DEFINITIONS
|
|
5 hex
|
|
6
|
|
7 8 +load \ relocate
|
|
8 1 6 +THRU
|
|
9 \ 7 +load \ System Assembler
|
|
10 decimal
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
Screen 3 not modified
|
|
0 \ FORTH-83 6502-ASSEMBLER ) er14dez88
|
|
1 : END-CODE CONTEXT 2- @ CONTEXT ! ;
|
|
2 CREATE INDEX
|
|
3 09 c, 09 c, 05 c, 15 c, 15 c, 01 c, 11 c, 80 c,
|
|
4 09 c, 80 c, 0D c, 1D c, 19 c, 80 c, 80 c, 80 c,
|
|
5 80 c, 00 c, 04 c, 14 c, 14 c, 80 c, 80 c, 80 c,
|
|
6 80 c, 80 c, 0C c, 1C c, 1C c, 80 c, 80 c, 2C c,
|
|
7
|
|
8 | VARIABLE MODE
|
|
9
|
|
10 : MODE: ( N -) CREATE C, DOES> ( -) C@ MODE ! ;
|
|
11
|
|
12 0 MODE: .A 1 MODE: # 2 | MODE: MEM 3 MODE: ,X
|
|
13 4 MODE: ,Y 5 MODE: X) 6 MODE: )Y 0F MODE: )
|
|
14 6 MODE: )Y 0F MODE: ) 6 MODE: )Y 0F MODE: )
|
|
15 6 MODE: )Y 0F MODE: ) 6 MODE: )Y 0F MODE: )
|
|
Screen 4 not modified
|
|
0 \ UPMODE CPU ) er14dez88
|
|
1 | : UPMODE ( ADDR0 F0 - ADDR1 F1)
|
|
2 IF MODE @ 8 OR MODE ! THEN 1 MODE @ 0F AND ?DUP IF
|
|
3 0 DO DUP + LOOP THEN OVER 1+ @ AND 0= ;
|
|
4
|
|
5 : CPU ( 8B -) CREATE C, DOES> ( -) C@ >c, MEM ;
|
|
6
|
|
7 00 CPU BRK 18 CPU CLC D8 CPU CLD
|
|
8 58 CPU CLI B8 CPU CLV CA CPU DEX
|
|
9 88 CPU DEY E8 CPU INX C8 CPU INY
|
|
10 EA CPU NOP 48 CPU PHA 08 CPU PHP
|
|
11 68 CPU PLA 28 CPU PLP 40 CPU RTI
|
|
12 60 CPU RTS 38 CPU SEC F8 CPU SED
|
|
13 78 CPU SEI AA CPU TAX A8 CPU TAY
|
|
14 BA CPU TSX 8A CPU TXA 9A CPU TXS
|
|
15 98 CPU TYA
|
|
Screen 5 not modified
|
|
0 \ M/CPU ) er14dez88
|
|
1
|
|
2 : M/CPU ( MODE OPCODE -) CREATE C, , DOES>
|
|
3 DUP 1+ @ 80 AND IF 10 MODE +! THEN OVER FF00 AND UPMODE UPMODE
|
|
4 IF MEM TRUE ABORT" INVALID" THEN
|
|
5 C@ MODE @ INDEX + C@ + >c, MODE @ 7 AND
|
|
6 IF MODE @ 0F AND 7 < IF >c, ELSE >, THEN THEN MEM ;
|
|
7
|
|
8 1C6E 60 M/CPU ADC 1C6E 20 M/CPU AND 1C6E C0 M/CPU CMP
|
|
9 1C6E 40 M/CPU EOR 1C6E A0 M/CPU LDA 1C6E 00 M/CPU ORA
|
|
10 1C6E E0 M/CPU SBC 1C6C 80 M/CPU STA 0D0D 01 M/CPU ASL
|
|
11 0C0C C1 M/CPU DEC 0C0C E1 M/CPU INC 0D0D 41 M/CPU LSR
|
|
12 0D0D 21 M/CPU ROL 0D0D 61 M/CPU ROR 0414 81 M/CPU STX
|
|
13 0486 E0 M/CPU CPX 0486 C0 M/CPU CPY 1496 A2 M/CPU LDX
|
|
14 0C8E A0 M/CPU LDY 048C 80 M/CPU STY 0480 14 M/CPU JSR
|
|
15 8480 40 M/CPU JMP 0484 20 M/CPU BIT
|
|
Screen 6 not modified
|
|
0 \ ASSEMBLER CONDITIONALS ) er14dez88
|
|
1
|
|
2 | : RANGE? ( BRANCH -- BRANCH )
|
|
3 DUP ABS 07F U> ABORT" OUT OF RANGE " ;
|
|
4
|
|
5 : [[ ( BEGIN) >here ;
|
|
6 : ?] ( UNTIL) >c, >here 1+ - RANGE? >c, ;
|
|
7 : ?[ ( IF) >c, >here 0 >c, ;
|
|
8 : ?[[ ( WHILE) ?[ SWAP ;
|
|
9 : ]? ( THEN) >here OVER >c@ IF SWAP >!
|
|
10 ELSE OVER 1+ - RANGE? SWAP >c! THEN ;
|
|
11 : ][ ( ELSE) >here 1+ 1 JMP
|
|
12 SWAP >here OVER 1+ - RANGE? SWAP >c! ;
|
|
13 : ]] ( AGAIN) JMP ;
|
|
14 : ]]? ( REPEAT) JMP ]? ;
|
|
15
|
|
Screen 7 not modified
|
|
0 \ ASSEMBLER CONDITIONALS ) er14dez88
|
|
1
|
|
2 90 CONSTANT CS B0 CONSTANT CC
|
|
3 D0 CONSTANT 0= F0 CONSTANT 0<>
|
|
4 10 CONSTANT 0< 30 CONSTANT 0>=
|
|
5 50 CONSTANT VS 70 CONSTANT VC
|
|
6
|
|
7 : NOT 20 [ FORTH ] XOR ;
|
|
8
|
|
9 : BEQ 0<> ?] ; : BMI 0>= ?] ;
|
|
10 : BNE 0= ?] ; : BPL 0< ?] ;
|
|
11 : BCC CS ?] ; : BVC VS ?] ;
|
|
12 : BCS CC ?] ; : BVS VC ?] ;
|
|
13
|
|
14
|
|
15
|
|
Screen 8 not modified
|
|
0 \ 2INC/2DEC WINC/WDEC KS 19 MAY 84 ) er14dez88
|
|
1
|
|
2 : 2INC
|
|
3 DUP LDA CLC 2 # ADC DUP STA CS ?[ SWAP 1+ INC ]? ;
|
|
4
|
|
5 : 2DEC
|
|
6 DUP LDA SEC 2 # SBC DUP STA CC ?[ SWAP 1+ DEC ]? ;
|
|
7
|
|
8 : WINC DUP INC 0= ?[ SWAP 1+ INC ]? ;
|
|
9
|
|
10 : WDEC DUP LDA 0= ?[ OVER 1+ DEC ]? DEC ;
|
|
11
|
|
12 : ;C: RECOVER JSR END-CODE ] 0 LAST ! 0 ;
|
|
13
|
|
14
|
|
15
|
|
Screen 9 not modified
|
|
0 \ ;CODE CODE CODE> BP 03 02 85) er14dez88
|
|
1 ONLYFORTH
|
|
2
|
|
3 : ASSEMBLER ASSEMBLER [ ASSEMBLER ] MEM ;
|
|
4
|
|
5 : ;CODE [COMPILE] DOES> -3 >allot
|
|
6 [COMPILE] ; -2 >allot ASSEMBLER ; IMMEDIATE
|
|
7
|
|
8 : CODE CREATE >here DUP 2- >! ASSEMBLER ;
|
|
9
|
|
10 : >LABEL ( ADR -)
|
|
11 >here | CREATE SWAP , 4 HALLOT
|
|
12 HEAP 1 AND HALLOT ( 6502-ALIGN) HERE 4 - HEAP 4 CMOVE
|
|
13 HEAP LAST @ COUNT 01F AND + ! DP ! DOES> ( - ADR) @ ;
|
|
14
|
|
15 : LABEL [ ASSEMBLER ] >here >LABEL ASSEMBLER ;
|
|
Screen 10 not modified
|
|
0 \ Code generating primitives er14dez88
|
|
1
|
|
2 Variable >codes
|
|
3 | Create nrc ] c, , c@ here allot ! c! [
|
|
4
|
|
5 : nonrelocate nrc >codes ! ; nonrelocate
|
|
6
|
|
7 | : >exec Create c,
|
|
8 Does> c@ >codes @ + @ execute ;
|
|
9
|
|
10 | 0 >exec >c, | 2 >exec >, | 4 >exec >c@
|
|
11 | 6 >exec >here | 8 >exec >allot | $0A >exec >!
|
|
12 | $0C >exec >c!
|
|
13
|
|
14
|
|
15
|
|
Screen 11 not modified
|
|
0 \ FORTH-65 ASSEMBLER WFR ) er14dez88
|
|
1 ( BASIS: FORTH DIMENSIONS VOL III NO. 5)
|
|
2 ONLYFORTH
|
|
3
|
|
4 ASSEMBLER ALSO DEFINITIONS
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|