Adding sources.

This commit is contained in:
Zellyn Hunter 2014-05-13 08:10:55 -07:00
parent 4279c0e0eb
commit a32cd8bd12
8 changed files with 8304 additions and 0 deletions

View File

@ -0,0 +1,575 @@
n ..###..
n .#...#.
n .#.#.#.
n .#.#.#.
n .#.##..
n .#.....
n ..####.
n .......
n ...#...
n ..#.#..
n .#...#.
n .#...#.
n .#####.
n .#...#.
n .#...#.
n .......
n .####..
n .#...#.
n .#...#.
n .####..
n .#...#.
n .#...#.
n .####..
n .......
n ..###..
n .#...#.
n .#.....
n .#.....
n .#.....
n .#...#.
n ..###..
n .......
n .####..
n .#...#.
n .#...#.
n .#...#.
n .#...#.
n .#...#.
n .####..
n .......
n .#####.
n .#.....
n .#.....
n .####..
n .#.....
n .#.....
n .#####.
n .......
n .#####.
n .#.....
n .#.....
n .####..
n .#.....
n .#.....
n .#.....
n .......
n ..####.
n .#.....
n .#.....
n .#..##.
n .#...#.
n .#...#.
n ..####.
n .......
n .#...#.
n .#...#.
n .#...#.
n .#####.
n .#...#.
n .#...#.
n .#...#.
n .......
n ..###..
n ...#...
n ...#...
n ...#...
n ...#...
n ...#...
n ..###..
n .......
n .....#.
n .....#.
n .....#.
n .....#.
n .....#.
n .#...#.
n ..###..
n .......
n .#...#.
n .#..#..
n .#.#...
n .##....
n .#.#...
n .#..#..
n .#...#.
n .......
n .#.....
n .#.....
n .#.....
n .#.....
n .#.....
n .#.....
n .#####.
n .......
n .#...#.
n .##.##.
n .#.#.#.
n .#.#.#.
n .#...#.
n .#...#.
n .#...#.
n .......
n .#...#.
n .#...#.
n .##..#.
n .#.#.#.
n .#..##.
n .#...#.
n .#...#.
n .......
n ..###..
n .#...#.
n .#...#.
n .#...#.
n .#...#.
n .#...#.
n ..###..
n .......
n .####..
n .#...#.
n .#...#.
n .####..
n .#.....
n .#.....
n .#.....
n .......
n ..###..
n .#...#.
n .#...#.
n .#...#.
n .#.#.#.
n .#..#..
n ..##.#.
n .......
n .####..
n .#...#.
n .#...#.
n .####..
n .#.#...
n .#..#..
n .#...#.
n .......
n ..###..
n .#...#.
n .#.....
n ..###..
n .....#.
n .#...#.
n ..###..
n .......
n .#####.
n ...#...
n ...#...
n ...#...
n ...#...
n ...#...
n ...#...
n .......
n .#...#.
n .#...#.
n .#...#.
n .#...#.
n .#...#.
n .#...#.
n ..###..
n .......
n .#...#.
n .#...#.
n .#...#.
n .#...#.
n .#...#.
n ..#.#..
n ...#...
n .......
n .#...#.
n .#...#.
n .#...#.
n .#.#.#.
n .#.#.#.
n .##.##.
n .#...#.
n .......
n .#...#.
n .#...#.
n ..#.#..
n ...#...
n ..#.#..
n .#...#.
n .#...#.
n .......
n .#...#.
n .#...#.
n ..#.#..
n ...#...
n ...#...
n ...#...
n ...#...
n .......
n .#####.
n .....#.
n ....#..
n ...#...
n ..#....
n .#.....
n .#####.
n .......
n .#####.
n .##....
n .##....
n .##....
n .##....
n .##....
n .#####.
n .......
n .......
n .#.....
n ..#....
n ...#...
n ....#..
n .....#.
n .......
n .......
n .#####.
n ....##.
n ....##.
n ....##.
n ....##.
n ....##.
n .#####.
n .......
n ...#...
n ..#.#..
n .#...#.
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n .#####.
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n ...#...
n ...#...
n ...#...
n ...#...
n ...#...
n .......
n ...#...
n .......
n ..#.#..
n ..#.#..
n ..#.#..
n .......
n .......
n .......
n .......
n .......
n ..#.#..
n ..#.#..
n .#####.
n ..#.#..
n .#####.
n ..#.#..
n ..#.#..
n .......
n ...#...
n ..####.
n .#.#...
n ..###..
n ...#.#.
n .####..
n ...#...
n .......
n .##..#.
n .##..#.
n ....#..
n ...#...
n ..#....
n .#..##.
n .#..##.
n .......
n ..##...
n .#..#..
n .#.#...
n ..#....
n .#.#.#.
n .#..#..
n ..##.#.
n .......
n ...#...
n ...#...
n ...#...
n .......
n .......
n .......
n .......
n .......
n ...#...
n ..#....
n .#.....
n .#.....
n .#.....
n ..#....
n ...#...
n .......
n ...#...
n ....#..
n .....#.
n .....#.
n .....#.
n ....#..
n ...#...
n .......
n ...#...
n .#.#.#.
n ..###..
n ...#...
n ..###..
n .#.#.#.
n ...#...
n .......
n .......
n ...#...
n ...#...
n .#####.
n ...#...
n ...#...
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n ..##...
n ...#...
n ..#....
n .......
n .......
n .......
n ..###..
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n .......
n ..##...
n ..##...
n .......
n .......
n .....#.
n ....#..
n ...#...
n ..#....
n .#.....
n .......
n .......
n ..###..
n .#...#.
n .#..##.
n .#.#.#.
n .##..#.
n .#...#.
n ..###..
n .......
n ...#...
n ..##...
n ...#...
n ...#...
n ...#...
n ...#...
n ..###..
n .......
n ..###..
n .#...#.
n .....#.
n ...##..
n ..#....
n .#.....
n .#####.
n .......
n .#####.
n .....#.
n ....#..
n ...##..
n .....#.
n .#...#.
n ..###..
n .......
n ....#..
n ...##..
n ..#.#..
n .#..#..
n .#####.
n ....#..
n ....#..
n .......
n .#####.
n .#.....
n .####..
n .....#.
n .....#.
n .#...#.
n ..###..
n .......
n ...###.
n ..#....
n .#.....
n .####..
n .#...#.
n .#...#.
n ..###..
n .......
n .#####.
n .....#.
n ....#..
n ...#...
n ..#....
n ..#....
n ..#....
n .......
n ..###..
n .#...#.
n .#...#.
n ..###..
n .#...#.
n .#...#.
n ..###..
n .......
n ..###..
n .#...#.
n .#...#.
n ..####.
n .....#.
n ....#..
n .###...
n .......
n .......
n .......
n ..##...
n ..##...
n .......
n ..##...
n ..##...
n .......
n .......
n .......
n ..##...
n ..##...
n .......
n ..##...
n ...#...
n ..#....
n ....#..
n ...#...
n ..#....
n .#.....
n ..#....
n ...#...
n ....#..
n .......
n .......
n .......
n .####..
n .......
n .####..
n .......
n .......
n .......
n ..#....
n ...#...
n ....#..
n .....#.
n ....#..
n ...#...
n ..#....
n .......
n ..###..
n .#...#.
n ....#..
n ...#...
n ...#...
n .......
n ...#...
n .......

File diff suppressed because it is too large Load Diff

154
source/redbook/fp.asm Normal file
View File

@ -0,0 +1,154 @@
***********************
* *
* APPLE-II FLOATING *
* POINT ROUTINES *
* *
* COPYRIGHT 1977 BY *
* APPLE COMPUTER INC. *
* *
* ALL RIGHTS RESERVED *
* *
* S. WOZNIAK *
* *
***********************
TITLE "FLOATING POINT ROUTINES"
SIGN EPZ $F3
X2 EPZ $F4
M2 EPZ $F5
X1 EPZ $F8
M1 EPZ $F9
E EPZ $FC
OVLOC EQU $3F5
ORG $F425
F425: 18 ADD CLC CLEAR CARRY
F426: A2 02 LDX #$2 INDEX FOR 3-BYTE ADD.
F428: B5 F9 ADD1 LDA M1,X
F42A: 75 F5 ADC M2,X ADD A BYTE OF MANT2 TO MANT1
F42C: 95 F9 STA M1,X
F42E: CA DEX INDEX TO NEXT MORE SIGNIF. BYTE.
F42F: 10 F7 BPL ADD1 LOOP UNTIL DONE.
F431: 60 RTS RETURN
F432: 06 F3 MD1 ASL SIGN CLEAR LSB OF SIGN.
F434: 20 37 F4 JSR ABSWAP ABS VAL OF M1, THEN SWAP WITH M2
F437: 24 F9 ABSWAP BIT M1 MANT1 NEGATIVE?
F439: 10 05 BPL ABSWAP1 NO, SWAP WITH MANT2 AND RETURN.
F43B: 20 A4 F4 JSR FCOMPL YES, COMPLEMENT IT.
F43E: E6 F3 INC SIGN INCR SIGN, COMPLEMENTING LSB.
F440: 38 ABSWAP1 SEC SET CARRY FOR RETURN TO MUL/DIV.
F441: A2 04 SWAP LDX #$4 INDEX FOR 4 BYTE SWAP.
F443: 94 FB SWAP1 STY E-1,X
F445: B5 F7 LDA X1-1,X SWAP A BYTE OF EXP/MANT1 WITH
F447: B4 F3 LDY X2-1,X EXP/MANT2 AND LEAVE A COPY OF
F449: 94 F7 STY X1-1,X MANT1 IN E (3 BYTES). E+3 USED
F44B: 95 F3 STA X2-1,X
F44D: CA DEX ADVANCE INDEX TO NEXT BYTE
F44E: D0 F3 BNE SWAP1 LOOP UNTIL DONE.
F450: 60 RTS RETURN
F451: A9 8E FLOAT LDA #$8E INIT EXP1 TO 14,
F453: 85 F8 STA X1 THEN NORMALIZE TO FLOAT.
F455: A5 F9 NORM1 LDA M1 HIGH-ORDER MANT1 BYTE.
F457: C9 C0 CMP #$C0 UPPER TWO BITS UNEQUAL?
F459: 30 0C BMI RTS1 YES, RETURN WITH MANT1 NORMALIZED
F45B: C6 F8 DEC X1 DECREMENT EXP1.
F45D: 06 FB ASL M1+2
F45F: 26 FA ROL M1+1 SHIFT MANT1 (3 BYTES) LEFT.
F461: 26 F9 ROL M1
F463: A5 F8 NORM LDA X1 EXP1 ZERO?
F465: D0 EE BNE NORM1 NO, CONTINUE NORMALIZING.
F467: 60 RTS1 RTS RETURN.
F468: 20 A4 F4 FSUB JSR FCOMPL CMPL MANT1,CLEARS CARRY UNLESS 0
F46B: 20 7B F4 SWPALGN JSR ALGNSWP RIGHT SHIFT MANT1 OR SWAP WITH
F46E: A5 F4 FADD LDA X2
F470: C5 F8 CMP X1 COMPARE EXP1 WITH EXP2.
F472: D0 F7 BNE SWPALGN IF #,SWAP ADDENDS OR ALIGN MANTS.
F474: 20 25 F4 JSR ADD ADD ALIGNED MANTISSAS.
F477: 50 EA ADDEND BVC NORM NO OVERFLOW, NORMALIZE RESULT.
F479: 70 05 BVS RTLOG OV: SHIFT M1 RIGHT, CARRY INTO SIGN
F47B: 90 C4 ALGNSWP BCC SWAP SWAP IF CARRY CLEAR,
* ELSE SHIFT RIGHT ARITH.
F47D: A5 F9 RTAR LDA M1 SIGN OF MANT1 INTO CARRY FOR
F47F: 0A ASL RIGHT ARITH SHIFT.
F480: E6 F8 RTLOG INC X1 INCR X1 TO ADJUST FOR RIGHT SHIFT
F482: F0 75 BEQ OVFL EXP1 OUT OF RANGE.
F484: A2 FA RTLOG1 LDX #$FA INDEX FOR 6:BYTE RIGHT SHIFT.
F486: 76 FF ROR1 ROR E+3,X
F488: E8 INX NEXT BYTE OF SHIFT.
F489: D0 FB BNE ROR1 LOOP UNTIL DONE.
F48B: 60 RTS RETURN.
F48C: 20 32 F4 FMUL JSR MD1 ABS VAL OF MANT1, MANT2
F48F: 65 F8 ADC X1 ADD EXP1 TO EXP2 FOR PRODUCT EXP
F491: 20 E2 F4 JSR MD2 CHECK PROD. EXP AND PREP. FOR MUL
F494: 18 CLC CLEAR CARRY FOR FIRST BIT.
F495: 20 84 F4 MUL1 JSR RTLOG1 M1 AND E RIGHT (PROD AND MPLIER)
F498: 90 03 BCC MUL2 IF CARRY CLEAR, SKIP PARTIAL PROD
F49A: 20 25 F4 JSR ADD ADD MULTIPLICAND TO PRODUCT.
F49D: 88 MUL2 DEY NEXT MUL ITERATION.
F49E: 10 F5 BPL MUL1 LOOP UNTIL DONE.
F4A0: 46 F3 MDEND LSR SIGN TEST SIGN LSB.
F4A2: 90 BF NORMX BCC NORM IF EVEN,NORMALIZE PROD,ELSE COMP
F4A4: 38 FCOMPL SEC SET CARRY FOR SUBTRACT.
F4A5: A2 03 LDX #$3 INDEX FOR 3 BYTE SUBTRACT.
F4A7: A9 00 COMPL1 LDA #$0 CLEAR A.
F4A9: F5 F8 SBC X1,X SUBTRACT BYTE OF EXP1.
F4AB: 95 F8 STA X1,X RESTORE IT.
F4AD: CA DEX NEXT MORE SIGNIFICANT BYTE.
F4AE: D0 F7 BNE COMPL1 LOOP UNTIL DONE.
F4B0: F0 C5 BEQ ADDEND NORMALIZE (OR SHIFT RT IF OVFL).
F4B2: 20 32 F4 FDIV JSR MD1 TAKE ABS VAL OF MANT1, MANT2.
F4B5: E5 F8 SBC X1 SUBTRACT EXP1 FROM EXP2.
F4B7: 20 E2 F4 JSR MD2 SAVE AS QUOTIENT EXP.
F4BA: 38 DIV1 SEC SET CARRY FOR SUBTRACT.
F4BB: A2 02 LDX #$2 INDEX FOR 3-BYTE SUBTRACTION.
F4BD: B5 F5 DIV2 LDA M2,X
F4BF: F5 FC SBC E,X SUBTRACT A BYTE OF E FROM MANT2.
F4C1: 48 PHA SAVE ON STACK.
F4C2: CA DEX NEXT MORE SIGNIFICANT BYTE.
F4C3: 10 F8 BPL DIV2 LOOP UNTIL DONE.
F4C5: A2 FD LDX #$FD INDEX FOR 3-BYTE CONDITIONAL MOVE
F4C7: 68 DIV3 PLA PULL BYTE OF DIFFERENCE OFF STACK
F4C8: 90 02 BCC DIV4 IF M2<E THEN DON'T RESTORE M2.
F4CA: 95 F8 STA M2+3,X
F4CC: E8 DIV4 INX NEXT LESS SIGNIFICANT BYTE.
F4CD: D0 F8 BNE DIV3 LOOP UNTIL DONE.
F4CF: 26 FB ROL M1+2
F4D1: 26 FA ROL M1+1 ROLL QUOTIENT LEFT, CARRY INTO LSB
F4D3: 26 F9 ROL M1
F4D5: 06 F7 ASL M2+2
F4D7: 26 F6 ROL M2+1 SHIFT DIVIDEND LEFT
F4D9: 26 F5 ROL M2
F4DB: B0 1C BCS OVFL OVFL IS DUE TO UNNORMED DIVISOR
F4DD: 88 DEY NEXT DIVIDE ITERATION.
F4DE: D0 DA BNE DIV1 LOOP UNTIL DONE 23 ITERATIONS.
F4E0: F0 BE BEQ MDEND NORM. QUOTIENT AND CORRECT SIGN.
F4E2: 86 FB MD2 STX M1+2
F4E4: 86 FA STX M1+1 CLEAR MANT1 (3 BYTES) FOR MUL/DIV.
F4E6: 86 F9 STX M1
F4E8: B0 0D BCS OVCHK IF CALC. SET CARRY,CHECK FOR OVFL
F4EA: 30 04 BMI MD3 IF NEG THEN NO UNDERFLOW.
F4EC: 68 PLA POP ONE RETURN LEVEL.
F4ED: 68 PLA
F4EE: 90 B2 BCC NORMX CLEAR X1 AND RETURN.
F4F0: 49 80 MD3 EOR #$80 COMPLEMENT SIGN BIT OF EXPONENT.
F4F2: 85 F8 STA X1 STORE IT.
F4F4: A0 17 LDY #$17 COUNT 24 MUL/23 DIV ITERATIONS.
F4F6: 60 RTS RETURN.
F4F7: 10 F7 OVCHK BPL MD3 IF POSITIVE EXP THEN NO OVFL.
F4F9: 4C F5 03 OVFL JMP OVLOC
ORG $F63D
F63D: 20 7D F4 FIX1 JSR RTAR
F640: A5 F8 FIX LDA X1
F642: 10 13 BPL UNDFL
F644: C9 8E CMP #$8E
F646: D0 F5 BNE FIX1
F648: 24 F9 BIT M1
F64A: 10 0A BPL FIXRTS
F64C: A5 FB LDA M1+2
F64E: F0 06 BEQ FIXRTS
F650: E6 FA INC M1+1
F652: D0 02 BNE FIXRTS
F654: E6 F9 INC M1
F656: 60 FIXRTS RTS
F657: A9 00 UNDFL LDA #$0
F659: 85 F9 STA M1
F65B: 85 FA STA M1+1
F65D: 60 RTS

43
source/redbook/info.org Normal file
View File

@ -0,0 +1,43 @@
* Sources from
- http://www.easy68k.com/paulrsm/6502/
- http://www.classiccmp.org/cini/pdf/Apple/
* Memory map of the Apple II ROMs
http://www.easy68k.com/paulrsm/6502/MEMMAP.HTM
| $F800-$FFFF | Monitor. Handles screen I/O and keyboard input. Also has a |
| monitor.asm | disassembler, memory dump, memory move, memory compare, step and trace |
| | functions, lo-res graphics routines, multiply and divide routines, and |
| | more. This monitor has the cleanest code of all the Apple II |
| | monitors. Every one after this had to patch the monitor to add |
| | functions while still remaining (mostly) compatible. Complete source |
| | code is in the manual. |
| | |
| $F689-F7FC | Sweet-16 interpreter. Sweet-16 code has been benchmarked to be about |
| sweet16.asm | half the size of pure 6502 code but 5-8 times slower. The renumber |
| | routine in the Programmer's Aid #1 is written in Sweet-16, where small |
| | size was much more important than speed. Complete source code is in |
| | the manual. |
| | |
| $F500-F63C | Mini-assembler. This lets you type in assembly code, one line at a |
| $F666-F668 | time, and it will assemble the proper bytes. No labels or equates are |
| miniasm.asm | supported--it is a MINI assembler. Complete source code is in the |
| | manual. |
| | |
| $F425-F4FB | Floating point routines. Woz's first plans for his 6502 BASIC included |
| $F63D-F65D | floating point, but he abandoned them when he realized he could finish |
| fp.asm | faster by going integer only. He put these routines in the ROMs but |
| | they are not called from anywhere. Complete source code is in the |
| | manual. |
| | |
| $E000-F424 | Integer BASIC by Woz (Steve Wozniak, creator of the Apple II). "That |
| intbasic.asm | BASIC, which we shipped with the first Apple II's, was never |
| | assembled--ever. There was one handwritten copy, all handwritten, all |
| | hand assembled." Woz, October 1984. |
| | |
| $D800-DFFF | Empty ROM socket. There was at least one third party ROM add-on. |
| | |
| $D000-D7FF | Programmer's Aid #1--missing from the original Apple II, this is a ROM |
| | add-on Apple sold that contains Integer BASIC utilities such as |
| | high-resolution graphics support, renumber, append, tape verify, |
| | music, and a RAM test. Complete source code is in the manual. |

3594
source/redbook/intbasic.asm Normal file

File diff suppressed because it is too large Load Diff

207
source/redbook/miniasm.asm Normal file
View File

@ -0,0 +1,207 @@
1 ***********************
2 * *
3 * APPLE-II *
4 * MINI-ASSEMBLER *
5 * *
6 * COPYRIGHT 1977 BY *
7 * APPLE COMPUTER INC. *
8 * *
9 * ALL RIGHTS RESERVED *
10 * *
11 * S. WOZNIAK *
12 * A. BAUM *
13 ***********************
14 ; TITLE "APPLE-II MINI-ASSEMBLER"
15 FORMAT EQU $2E
16 LENGTH EQU $2F
17 MODE EQU $31
18 PROMPT EQU $33
19 YSAV EQU $34
20 L EQU $35
21 PCL EQU $3A
22 PCH EQU $3B
23 A1H EQU $3D
24 A2L EQU $3E
25 A2H EQU $3F
26 A4L EQU $42
27 A4H EQU $43
28 FMT EQU $44
29 IN EQU $200
30 INSDS2 EQU $F88E
31 INSTDSP EQU $F8D0
32 PRBL2 EQU $F94A
33 PCADJ EQU $F953
34 CHAR1 EQU $F9B4
35 CHAR2 EQU $F9BA
36 MNEML EQU $F9C0
37 MNEMR EQU $FA00
38 CURSUP EQU $FC1A
39 GETLNZ EQU $FD67
40 COUT EQU $FDED
41 BL1 EQU $FE00
42 A1PCLP EQU $FE78
43 BELL EQU $FF3A
44 GETNUM EQU $FFA7
45 TOSUB EQU $FFBE
46 ZMODE EQU $FFC7
47 CHRTBL EQU $FFCC
48 ORG $F500
F500: E9 81 49 REL SBC #$81 ;IS FMT COMPATIBLE
F502: 4A 50 LSR ;WITH RELATIVE MODE?
F503: D0 14 51 BNE ERR3 ; NO.
F505: A4 3F 52 LDY A2H
F507: A6 3E 53 LDX A2L ;DOUBLE DECREMENT
F509: D0 01 54 BNE REL2
F50B: 88 55 DEY
F50C: CA 56 REL2 DEX
F50D: 8A 57 TXA
F50E: 18 58 CLC
F50F: E5 3A 59 SBC PCL ;FORM ADDR-PC-2
F511: 85 3E 60 STA A2L
F513: 10 01 61 BPL REL3
F515: C8 62 INY
F516: 98 63 REL3 TYA
F517: E5 3B 64 SBC PCH
F519: D0 6B 65 ERR3 BNE ERR ;ERROR IF >1-BYTE BRANCH
F51B: A4 2F 66 FINDOP LDY LENGTH
F51D: B9 3D 00 67 FNDOP2 LDA A1H,Y ;MOVE INST TO (PC)
F520: 91 3A 68 STA (PCL),Y
F522: 88 69 DEY
F523: 10 F8 70 BPL FNDOP2
F525: 20 1A FC 71 JSR CURSUP
F528: 20 1A FC 72 JSR CURSUP ;RESTORE CURSOR
F52B: 20 D0 F8 73 JSR INSTDSP ;TYPE FORMATTED LINE
F52E: 20 53 F9 74 JSR PCADJ ;UPDATE PC
F531: 84 3B 75 STY PCH
F533: 85 3A 76 STA PCL
F535: 4C 95 F5 77 JMP NXTLINE ;GET NEXT LINE
F538: 20 BE FF 78 FAKEMON3 JSR TOSUB ;GO TO DELIM HANDLER
F53B: A4 34 79 LDY YSAV ;RESTORE Y-INDEX
F53D: 20 A7 FF 80 FAKEMON JSR GETNUM ;READ PARAM
F540: 84 34 81 STY YSAV ;SAVE Y-INDEX
F542: A0 17 82 LDY #$17 ;INIT DELIMITER INDEX
F544: 88 83 FAKEMON2 DEY ;CHECK NEXT DELIM
F545: 30 4B 84 BMI RESETZ ;ERR IF UNRECOGNIZED DELIM
F547: D9 CC FF 85 CMP CHRTBL,Y ;COMPARE WITH DELIM TABLE
F54A: D0 F8 86 BNE FAKEMON2 ;NO MATCH
F54C: C0 15 87 CPY #$15 ;MATCH, IS IT CR?
F54E: D0 E8 88 BNE FAKEMON3 ;NO, HANDLE IT IN MONITOR
F550: A5 31 89 LDA MODE
F552: A0 00 90 LDY #$0
F554: C6 34 91 DEC YSAV
F556: 20 00 FE 92 JSR BL1 ;HANDLE CR OUTSIDE MONITOR
F559: 4C 95 F5 93 JMP NXTLINE
F55C: A5 3D 94 TRYNEXT LDA A1H ;GET TRIAL OPCODE
F55E: 20 8E F8 95 JSR INSDS2 ;GET FMT+LENGTH FOR OPCODE
F561: AA 96 TAX
F562: BD 00 FA 97 LDA MNEMR,X ;GET LOWER MNEMONIC BYTE
F565: C5 42 98 CMP A4L ;MATCH?
F567: D0 13 99 BNE NEXTOP ;NO, TRY NEXT OPCODE.
F569: BD C0 F9 100 LDA MNEML,X ;GET UPPER MNEMONIC BYTE
F56C: C5 43 101 CMP A4H ;MATCH?
F56E: D0 0C 102 BNE NEXTOP ;NO, TRY NEXT OPCODE
F570: A5 44 103 LDA FMT
F572: A4 2E 104 LDY FORMAT ;GET TRIAL FORMAT
F574: C0 9D 105 CPY #$9D ;TRIAL FORMAT RELATIVE?
F576: F0 88 106 BEQ REL ;YES.
F578: C5 2E 107 NREL CMP FORMAT ;SAME FORMAT?
F57A: F0 9F 108 BEQ FINDOP ;YES.
F57C: C6 3D 109 NEXTOP DEC A1H ;NO, TRY NEXT OPCODE
F57E: D0 DC 110 BNE TRYNEXT
F580: E6 44 111 INC FMT ;NO MORE, TRY WITH LEN=2
F582: C6 35 112 DEC L ;WAS L=2 ALREADY?
F584: F0 D6 113 BEQ TRYNEXT ;NO.
F586: A4 34 114 ERR LDY YSAV ;YES, UNRECOGNIZED INST.
F588: 98 115 ERR2 TYA
F589: AA 116 TAX
F58A: 20 4A F9 117 JSR PRBL2 ;PRINT ^ UNDER LAST READ
F58D: A9 DE 118 LDA #$DE ;CHAR TO INDICATE ERROR
F58F: 20 ED FD 119 JSR COUT ;POSITION.
F592: 20 3A FF 120 RESETZ JSR BELL
F595: A9 A1 121 NXTLINE LDA #$A1 ;'!'
F597: 85 33 122 STA PROMPT ;INITIALIZE PROMPT
F599: 20 67 FD 123 JSR GETLNZ ;GET LINE.
F59C: 20 C7 FF 124 JSR ZMODE ;INIT SCREEN STUFF
F59F: AD 00 02 125 LDA IN ;GET CHAR
F5A2: C9 A0 126 CMP #$A0 ;ASCII BLANK?
F5A4: F0 13 127 BEQ SPACE ;YES
F5A6: C8 128 INY
F5A7: C9 A4 129 CMP #$A4 ;ASCII '$' IN COL 1?
F5A9: F0 92 130 BEQ FAKEMON ;YES, SIMULATE MONITOR
F5AB: 88 131 DEY ;NO, BACKUP A CHAR
F5AC: 20 A7 FF 132 JSR GETNUM ;GET A NUMBER
F5AF: C9 93 133 CMP #$93 ;':' TERMINATOR?
F5B1: D0 D5 134 ERR4 BNE ERR2 ;NO, ERR.
F5B3: 8A 135 TXA
F5B4: F0 D2 136 BEQ ERR2 ;NO ADR PRECEDING COLON.
F5B6: 20 78 FE 137 JSR A1PCLP ;MOVE ADR TO PCL, PCH.
F5B9: A9 03 138 SPACE LDA #$3 ;COUNT OF CHARS IN MNEMONIC
F5BB: 85 3D 139 STA A1H
F5BD: 20 34 F6 140 NXTMN JSR GETNSP ;GET FIRST MNEM CHAR.
F5C0: 0A 141 NXTM ASL
F5C1: E9 BE 142 SBC #$BE ;SUBTRACT OFFSET
F5C3: C9 C2 143 CMP #$C2 ;LEGAL CHAR?
F5C5: 90 C1 144 BCC ERR2 ;NO.
F5C7: 0A 145 ASL ;COMPRESS-LEFT JUSTIFY
F5C8: 0A 146 ASL
F5C9: A2 04 147 LDX #$4
F5CB: 0A 148 NXTM2 ASL ;DO 5 TRIPLE WORD SHIFTS
F5CC: 26 42 149 ROL A4L
F5CE: 26 43 150 ROL A4H
F5D0: CA 151 DEX
F5D1: 10 F8 152 BPL NXTM2
F5D3: C6 3D 153 DEC A1H ;DONE WITH 3 CHARS?
F5D5: F0 F4 154 BEQ NXTM2 ;YES, BUT DO 1 MORE SHIFT
F5D7: 10 E4 155 BPL NXTMN ;NO
F5D9: A2 05 156 FORM1 LDX #$5 ;5 CHARS IN ADDR MODE
F5DB: 20 34 F6 157 FORM2 JSR GETNSP ;GET FIRST CHAR OF ADDR
F5DE: 84 34 158 STY YSAV
F5E0: DD B4 F9 159 CMP CHAR1,X ;FIRST CHAR MATCH PATTERN?
F5E3: D0 13 160 BNE FORM3 ;NO
F5E5: 20 34 F6 161 JSR GETNSP ;YES, GET SECOND CHAR
F5E8: DD BA F9 162 CMP CHAR2,X ;MATCHES SECOND HALF?
F5EB: F0 0D 163 BEQ FORM5 ;YES.
F5ED: BD BA F9 164 LDA CHAR2,X ;NO, IS SECOND HALF ZERO?
F5F0: F0 07 165 BEQ FORM4 ;YES.
F5F2: C9 A4 166 CMP #$A4 ;NO,SECOND HALF OPTIONAL?
F5F4: F0 03 167 BEQ FORM4 ;YES.
F5F6: A4 34 168 LDY YSAV
F5F8: 18 169 FORM3 CLC ;CLEAR BIT-NO MATCH
F5F9: 88 170 FORM4 DEY ;BACK UP 1 CHAR
F5FA: 26 44 171 FORM5 ROL FMT ;FORM FORMAT BYTE
F5FC: E0 03 172 CPX #$3 ;TIME TO CHECK FOR ADDR.
F5FE: D0 0D 173 BNE FORM7 ;NO
F600: 20 A7 FF 174 JSR GETNUM ;YES
F603: A5 3F 175 LDA A2H
F605: F0 01 176 BEQ FORM6 ;HIGH-ORDER BYTE ZERO
F607: E8 177 INX ;NO, INCR FOR 2-BYTE
F608: 86 35 178 FORM6 STX L ;STORE LENGTH
F60A: A2 03 179 LDX #$3 ;RELOAD FORMAT INDEX
F60C: 88 180 DEY ;BACKUP A CHAR
F60D: 86 3D 181 FORM7 STX A1H ;SAVE INDEX
F60F: CA 182 DEX ;DONE WITH FORMAT CHECK?
F610: 10 C9 183 BPL FORM2 ;NO.
F612: A5 44 184 LDA FMT ;YES, PUT LENGTH
F614: 0A 185 ASL ;IN LOW BITS
F615: 0A 186 ASL
F616: 05 35 187 ORA L
F618: C9 20 188 CMP #$20
F61A: B0 06 189 BCS FORM8 ;ADD "$" IF NONZERO LENGTH
F61C: A6 35 190 LDX L ;AND DON'T ALREADY HAVE IT
F61E: F0 02 191 BEQ FORM8
F620: 09 80 192 ORA #$80
F622: 85 44 193 FORM8 STA FMT
F624: 84 34 194 STY YSAV
F626: B9 00 02 195 LDA IN,Y ;GET NEXT NONBLANK
F629: C9 BB 196 CMP #$BB ;';' START OF COMMENT?
F62B: F0 04 197 BEQ FORM9 ;YES
F62D: C9 8D 198 CMP #$8D ;CARRIAGE RETURN?
F62F: D0 80 199 BNE ERR4 ;NO, ERR.
F631: 4C 5C F5 200 FORM9 JMP TRYNEXT
F634: B9 00 02 201 GETNSP LDA IN,Y
F637: C8 202 INY
F638: C9 A0 203 CMP #$A0 ;GET NEXT NON BLANK CHAR
F63A: F0 F8 204 BEQ GETNSP
F63C: 60 205 RTS
206 ORG $F666
F666: 4C 92 F5 207 MINIASM JMP RESETZ

1187
source/redbook/monitor.asm Normal file

File diff suppressed because it is too large Load Diff

241
source/redbook/sweet16.asm Normal file
View File

@ -0,0 +1,241 @@
1 ***********************
2 * *
3 * APPLE-II PSEUDO *
4 * MACHINE INTERPRETER *
5 * *
6 * COPYRIGHT 1977 *
7 * APPLE COMPUTER INC *
8 * *
9 * ALL RIGHTS RESERVED *
10 * S. WOZNIAK *
11 * *
12 ***********************
13 ; TITLE "SWEET16 INTERPRETER"
14 R0L EQU $0
15 R0H EQU $1
16 R14H EQU $1D
17 R15L EQU $1E
18 R15H EQU $1F
19 SW16PAG EQU $F7
20 SAVE EQU $FF4A
21 RESTORE EQU $FF3F
22 ORG $F689
F689: 20 4A FF 23 SW16 JSR SAVE ;PRESERVE 6502 REG CONTENTS
F68C: 68 24 PLA
F68D: 85 1E 25 STA R15L ;INIT SWEET16 PC
F68F: 68 26 PLA ;FROM RETURN
F690: 85 1F 27 STA R15H ; ADDRESS
F692: 20 98 F6 28 SW16B JSR SW16C ;INTERPRET AND EXECUTE
F695: 4C 92 F6 29 JMP SW16B ;ONE SWEET16 INSTR.
F698: E6 1E 30 SW16C INC R15L
F69A: D0 02 31 BNE SW16D ;INCR SWEET16 PC FOR FETCH
F69C: E6 1F 32 INC R15H
F69E: A9 F7 33 SW16D LDA #SW16PAG
F6A0: 48 34 PHA ;PUSH ON STACK FOR RTS
F6A1: A0 00 35 LDY #$0
F6A3: B1 1E 36 LDA (R15L),Y ;FETCH INSTR
F6A5: 29 0F 37 AND #$F ;MASK REG SPECIFICATION
F6A7: 0A 38 ASL ;DOUBLE FOR TWO BYTE REGISTERS
F6A8: AA 39 TAX ;TO X REG FOR INDEXING
F6A9: 4A 40 LSR
F6AA: 51 1E 41 EOR (R15L),Y ;NOW HAVE OPCODE
F6AC: F0 0B 42 BEQ TOBR ;IF ZERO THEN NON-REG OP
F6AE: 86 1D 43 STX R14H ;INDICATE'PRIOR RESULT REG'
F6B0: 4A 44 LSR
F6B1: 4A 45 LSR ;OPCODE*2 TO LSB'S
F6B2: 4A 46 LSR
F6B3: A8 47 TAY ;TO Y REG FOR INDEXING
F6B4: B9 E1 F6 48 LDA OPTBL-2,Y ;LOW ORDER ADR BYTE
F6B7: 48 49 PHA ;ONTO STACK
F6B8: 60 50 RTS ;GOTO REG-OP ROUTINE
F6B9: E6 1E 51 TOBR INC R15L
F6BB: D0 02 52 BNE TOBR2 ;INCR PC
F6BD: E6 1F 53 INC R15H
F6BF: BD E4 F6 54 TOBR2 LDA BRTBL,X ;LOW ORDER ADR BYTE
F6C2: 48 55 PHA ;ONTO STACK FOR NON-REG OP
F6C3: A5 1D 56 LDA R14H ;'PRIOR RESULT REG' INDEX
F6C5: 4A 57 LSR ;PREPARE CARRY FOR BC, BNC.
F6C6: 60 58 RTS ;GOTO NON-REG OP ROUTINE
F6C7: 68 59 RTNZ PLA ;POP RETURN ADDRESS
F6C8: 68 60 PLA
F6C9: 20 3F FF 61 JSR RESTORE ;RESTORE 6502 REG CONTENTS
F6CC: 6C 1E 00 62 JMP (R15L) ;RETURN TO 6502 CODE VIA PC
F6CF: B1 1E 63 SETZ LDA (R15L),Y ;HIGH-ORDER BYTE OF CONSTANT
F6D1: 95 01 64 STA R0H,X
F6D3: 88 65 DEY
F6D4: B1 1E 66 LDA (R15L),Y ;LOW-ORDER BYTE OF CONSTANT
F6D6: 95 00 67 STA R0L,X
F6D8: 98 68 TYA ;Y-REG CONTAINS 1
F6D9: 38 69 SEC
F6DA: 65 1E 70 ADC R15L ;ADD 2 TO PC
F6DC: 85 1E 71 STA R15L
F6DE: 90 02 72 BCC SET2
F6E0: E6 1F 73 INC R15H
F6E2: 60 74 SET2 RTS
F6E3: 02 75 OPTBL DFB SET-1 ;1X
F6E4: F9 76 BRTBL DFB RTN-1 ;0
F6E5: 04 77 DFB LD-1 ;2X
F6E6: 9D 78 DFB BR-1 ;1
F6E7: 0D 79 DFB ST-1 ;3X
F6E8: 9E 80 DFB BNC-1 ;2
F6E9: 25 81 DFB LDAT-1 ;4X
F6EA: AF 82 DFB BC-1 ;3
F6EB: 16 83 DFB STAT-1 ;5X
F6EC: B2 84 DFB BP-1 ;4
F6ED: 47 85 DFB LDDAT-1 ;6X
F6EE: B9 86 DFB BM-1 ;5
F6EF: 51 87 DFB STDAT-1 ;7X
F6F0: C0 88 DFB BZ-1 ;6
F6F1: 2F 89 DFB POP-1 ;8X
F6F2: C9 90 DFB BNZ-1 ;7
F6F3: 5B 91 DFB STPAT-1 ;9X
F6F4: D2 92 DFB BM1-1 ;8
F6F5: 85 93 DFB ADD-1 ;AX
F6F6: DD 94 DFB BNM1-1 ;9
F6F7: 6E 95 DFB SUB-1 ;BX
F6F8: 05 96 DFB BK-1 ;A
F6F9: 33 97 DFB POPD-1 ;CX
F6FA: E8 98 DFB RS-1 ;B
F6FB: 70 99 DFB CPR-1 ;DX
F6FC: 93 100 DFB BS-1 ;C
F6FD: 1E 101 DFB INR-1 ;EX
F6FE: E7 102 DFB NUL-1 ;D
F6FF: 65 103 DFB DCR-1 ;FX
F700: E7 104 DFB NUL-1 ;E
F701: E7 105 DFB NUL-1 ;UNUSED
F702: E7 106 DFB NUL-1 ;F
F703: 10 CA 107 SET BPL SETZ ;ALWAYS TAKEN
F705: B5 00 108 LD LDA R0L,X
109 BK EQU *-1
F707: 85 00 110 STA R0L
F709: B5 01 111 LDA R0H,X ;MOVE RX TO R0
F70B: 85 01 112 STA R0H
F70D: 60 113 RTS
F70E: A5 00 114 ST LDA R0L
F710: 95 00 115 STA R0L,X ;MOVE R0 TO RX
F712: A5 01 116 LDA R0H
F714: 95 01 117 STA R0H,X
F716: 60 118 RTS
F717: A5 00 119 STAT LDA R0L
F719: 81 00 120 STAT2 STA (R0L,X) ;STORE BYTE INDIRECT
F71B: A0 00 121 LDY #$0
F71D: 84 1D 122 STAT3 STY R14H ;INDICATE R0 IS RESULT NEG
F71F: F6 00 123 INR INC R0L,X
F721: D0 02 124 BNE INR2 ;INCR RX
F723: F6 01 125 INC R0H,X
F725: 60 126 INR2 RTS
F726: A1 00 127 LDAT LDA (R0L,X) ;LOAD INDIRECT (RX)
F728: 85 00 128 STA R0L ;TO R0
F72A: A0 00 129 LDY #$0
F72C: 84 01 130 STY R0H ;ZERO HIGH-ORDER R0 BYTE
F72E: F0 ED 131 BEQ STAT3 ;ALWAYS TAKEN
F730: A0 00 132 POP LDY #$0 ;HIGH ORDER BYTE = 0
F732: F0 06 133 BEQ POP2 ;ALWAYS TAKEN
F734: 20 66 F7 134 POPD JSR DCR ;DECR RX
F737: A1 00 135 LDA (R0L,X) ;POP HIGH ORDER BYTE @RX
F739: A8 136 TAY ;SAVE IN Y-REG
F73A: 20 66 F7 137 POP2 JSR DCR ;DECR RX
F73D: A1 00 138 LDA (R0L,X) ;LOW-ORDER BYTE
F73F: 85 00 139 STA R0L ;TO R0
F741: 84 01 140 STY R0H
F743: A0 00 141 POP3 LDY #$0 ;INDICATE R0 AS LAST RESULT REG
F745: 84 1D 142 STY R14H
F747: 60 143 RTS
F748: 20 26 F7 144 LDDAT JSR LDAT ;LOW-ORDER BYTE TO R0, INCR RX
F74B: A1 00 145 LDA (R0L,X) ;HIGH-ORDER BYTE TO R0
F74D: 85 01 146 STA R0H
F74F: 4C 1F F7 147 JMP INR ;INCR RX
F752: 20 17 F7 148 STDAT JSR STAT ;STORE INDIRECT LOW-ORDER
F755: A5 01 149 LDA R0H ;BYTE AND INCR RX. THEN
F757: 81 00 150 STA (R0L,X) ;STORE HIGH-ORDER BYTE.
F759: 4C 1F F7 151 JMP INR ;INCR RX AND RETURN
F75C: 20 66 F7 152 STPAT JSR DCR ;DECR RX
F75F: A5 00 153 LDA R0L
F761: 81 00 154 STA (R0L,X) ;STORE R0 LOW BYTE @RX
F763: 4C 43 F7 155 JMP POP3 ;INDICATE R0 AS LAST RSLT REG
F766: B5 00 156 DCR LDA R0L,X
F768: D0 02 157 BNE DCR2 ;DECR RX
F76A: D6 01 158 DEC R0H,X
F76C: D6 00 159 DCR2 DEC R0L,X
F76E: 60 160 RTS
F76F: A0 00 161 SUB LDY #$0 ;RESULT TO R0
F771: 38 162 CPR SEC ;NOTE Y-REG = 13*2 FOR CPR
F772: A5 00 163 LDA R0L
F774: F5 00 164 SBC R0L,X
F776: 99 00 00 165 STA R0L,Y ;R0-RX TO RY
F779: A5 01 166 LDA R0H
F77B: F5 01 167 SBC R0H,X
F77D: 99 01 00 168 SUB2 STA R0H,Y
F780: 98 169 TYA ;LAST RESULT REG*2
F781: 69 00 170 ADC #$0 ;CARRY TO LSB
F783: 85 1D 171 STA R14H
F785: 60 172 RTS
F786: A5 00 173 ADD LDA R0L
F788: 75 00 174 ADC R0L,X
F78A: 85 00 175 STA R0L ;R0+RX TO R0
F78C: A5 01 176 LDA R0H
F78E: 75 01 177 ADC R0H,X
F790: A0 00 178 LDY #$0 ;R0 FOR RESULT
F792: F0 E9 179 BEQ SUB2 ;FINISH ADD
F794: A5 1E 180 BS LDA R15L ;NOTE X-REG IS 12*2!
F796: 20 19 F7 181 JSR STAT2 ;PUSH LOW PC BYTE VIA R12
F799: A5 1F 182 LDA R15H
F79B: 20 19 F7 183 JSR STAT2 ;PUSH HIGH-ORDER PC BYTE
F79E: 18 184 BR CLC
F79F: B0 0E 185 BNC BCS BNC2 ;NO CARRY TEST
F7A1: B1 1E 186 BR1 LDA (R15L),Y ;DISPLACEMENT BYTE
F7A3: 10 01 187 BPL BR2
F7A5: 88 188 DEY
F7A6: 65 1E 189 BR2 ADC R15L ;ADD TO PC
F7A8: 85 1E 190 STA R15L
F7AA: 98 191 TYA
F7AB: 65 1F 192 ADC R15H
F7AD: 85 1F 193 STA R15H
F7AF: 60 194 BNC2 RTS
F7B0: B0 EC 195 BC BCS BR
F7B2: 60 196 RTS
F7B3: 0A 197 BP ASL ;DOUBLE RESULT-REG INDEX
F7B4: AA 198 TAX ;TO X REG FOR INDEXING
F7B5: B5 01 199 LDA R0H,X ;TEST FOR PLUS
F7B7: 10 E8 200 BPL BR1 ;BRANCH IF SO
F7B9: 60 201 RTS
F7BA: 0A 202 BM ASL ;DOUBLE RESULT-REG INDEX
F7BB: AA 203 TAX
F7BC: B5 01 204 LDA R0H,X ;TEST FOR MINUS
F7BE: 30 E1 205 BMI BR1
F7C0: 60 206 RTS
F7C1: 0A 207 BZ ASL ;DOUBLE RESULT-REG INDEX
F7C2: AA 208 TAX
F7C3: B5 00 209 LDA R0L,X ;TEST FOR ZERO
F7C5: 15 01 210 ORA R0H,X ;(BOTH BYTES)
F7C7: F0 D8 211 BEQ BR1 ;BRANCH IF SO
F7C9: 60 212 RTS
F7CA: 0A 213 BNZ ASL ;DOUBLE RESULT-REG INDEX
F7CB: AA 214 TAX
F7CC: B5 00 215 LDA R0L,X ;TEST FOR NON-ZERO
F7CE: 15 01 216 ORA R0H,X ;(BOTH BYTES)
F7D0: D0 CF 217 BNE BR1 ;BRANCH IF SO
F7D2: 60 218 RTS
F7D3: 0A 219 BM1 ASL ;DOUBLE RESULT-REG INDEX
F7D4: AA 220 TAX
F7D5: B5 00 221 LDA R0L,X ;CHECK BOTH BYTES
F7D7: 35 01 222 AND R0H,X ;FOR $FF (MINUS 1)
F7D9: 49 FF 223 EOR #$FF
F7DB: F0 C4 224 BEQ BR1 ;BRANCH IF SO
F7DD: 60 225 RTS
F7DE: 0A 226 BNM1 ASL ;DOUBLE RESULT-REG INDEX
F7DF: AA 227 TAX
F7E0: B5 00 228 LDA R0L,X
F7E2: 35 01 229 AND R0H,X ;CHECK BOTH BYTES FOR NO $FF
F7E4: 49 FF 230 EOR #$FF
F7E6: D0 B9 231 BNE BR1 ;BRANCH IF NOT MINUS 1
F7E8: 60 232 NUL RTS
F7E9: A2 18 233 RS LDX #$18 ;12*2 FOR R12 AS STACK POINTER
F7EB: 20 66 F7 234 JSR DCR ;DECR STACK POINTER
F7EE: A1 00 235 LDA (R0L,X) ;POP HIGH RETURN ADDRESS TO PC
F7F0: 85 1F 236 STA R15H
F7F2: 20 66 F7 237 JSR DCR ;SAME FOR LOW-ORDER BYTE
F7F5: A1 00 238 LDA (R0L,X)
F7F7: 85 1E 239 STA R15L
F7F9: 60 240 RTS
F7FA: 4C C7 F6 241 RTN JMP RTNZ