Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AS V1.42 Beta [Bld 77] - source file monitor68.asm - page 1 - 7/18/2011 15:27:38
- 1/ 0 : ; This is a rewrite of the Apple 1 monitor to run on an MC6800
- 2/ 0 : ; microprocessor, rather than the MCS6502 microprocessor that
- 3/ 0 : ; was standard. This source code will assemble with the
- 4/ 0 : ; AS Macro Assembler; with minor changes it should assemble
- 5/ 0 : ; with any MC6800 assembler.
- 6/ 0 :
- 7/ 0 : ; Copyright 2011 Eric Smith <eric@brouhaha.com>
- 8/ 0 : ;
- 9/ 0 : ; This program is free software; you can redistribute and/or modify it
- 10/ 0 : ; under the terms of the GNU General Public License version 3 as
- 11/ 0 : ; published by the Free Software Foundation.
- 12/ 0 : ;
- 13/ 0 : ; This program is distributed in the hope that it will be useful, but
- 14/ 0 : ; WITHOUT ANY WARRANTY; without even the implied warranty of
- 15/ 0 : ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- 16/ 0 : ; General Public License for more details.
- 17/ 0 : ;
- 18/ 0 : ; The text of the license may be found online at:
- 19/ 0 : ; http://www.brouhaha.com/~eric/software/GPLv3
- 20/ 0 : ; or:
- 21/ 0 : ; http://www.gnu.org/licenses/gpl-3.0.txt
- 22/ 0 :
- 23/ 0 : cpu 6800
- 24/ 0 :
- 25/ 0 : =$24 xam equ $0024 ; two bytes
- 26/ 0 : =$26 st equ $0026 ; two bytes
- 27/ 0 : =$28 h equ $0028
- 28/ 0 : =$29 l equ $0029
- 29/ 0 :
- 30/ 0 : =$2B mode equ $002b
- 31/ 0 : =$2C ysav equ $002c ; two bytes
- 32/ 0 : =$2E inptr equ $002e ; two bytes
- 33/ 0 :
- 34/ 0 : =$200 in equ $0200
- 35/ 0 :
- 36/ 0 : =$D010 kbd equ $d010
- 37/ 0 : =$D011 kbd_cr equ $d011
- 38/ 0 : =$D012 dsp equ $d012
- 39/ 0 : =$D013 dsp_cr equ $d013
- 40/ 0 :
- 41/ FF00 : org $ff00
- 42/ FF00 :
- 43/ FF00 : reset: ; cld ; No decimal mode on 6800, so we don't need
- 44/ FF00 : ; need to clear it.
- 45/ FF00 : ; cli ; Disable interrupts - not actually needed on reset.
- 46/ FF00 : C6 7F ldab #$7f ; Mask for DSP data direction register.
- 47/ FF02 : F7 D0 12 stab dsp ; Set it up.
- 48/ FF05 : C6 A7 ldab #$a7 ; KBD and DSP control register mask.
- 49/ FF07 : F7 D0 11 stab kbd_cr ; Enable interrupts, set CA1, CB1, for
- 50/ FF0A : F7 D0 13 stab dsp_cr ; positive edge sense/output mode.
- 51/ FF0D : 8E 01 FF lds #$01ff ; On the 6502, the monitor didn't initialize the
- 52/ FF10 : ; stack pointer, which was OK because it was
- 53/ FF10 : ; guaranteed to be somewhere in page 1. Not so
- 54/ FF10 : ; on the 6800!
- 55/ FF10 : ; Ideally, I'd take advantage of the stack
- 56/ FF10 : ; starting right before the input buffer to
- 57/ FF10 : ; save a few bytes, but I haven't yet figured
- 58/ FF10 : ; out how to do it.
- 59/ FF10 :
- 60/ FF10 : ; Note that B contains $a7 here, which means that the incb below will
- AS V1.42 Beta [Bld 77] - source file monitor68.asm - page 2 - 7/18/2011 15:27:38
- 61/ FF10 : ; set the negative flag, causing the bpl to fall through into escape.
- 62/ FF10 : ; This saves us a "bra escape" instruction here.
- 63/ FF10 :
- 64/ FF10 : ; Get a line of input from the keyboard, echoing to display.
- 65/ FF10 : ; Normally enter at escape or getline.
- 66/ FF10 :
- 67/ FF10 : 81 DF notcr: cmpa #$df ; "_"? [NB back arrow]
- 68/ FF12 : 27 17 beq backspace ; Yes.
- 69/ FF14 : 81 9B cmpa #$9b ; ESC?
- 70/ FF16 : 27 04 beq escape ; Yes.
- 71/ FF18 : 08 inx ; Advance text index.
- 72/ FF19 : 5C incb
- 73/ FF1A : 2A 13 bpl nextchar ; Auto ESC if > 127.
- 74/ FF1C :
- 75/ FF1C : 86 DC escape: ldaa #$dc ; "\".
- 76/ FF1E : BD FF B4 jsr echo ; Output it.
- 77/ FF21 :
- 78/ FF21 : 86 8D getline: ldaa #$8d ; CR.
- 79/ FF23 : BD FF B4 jsr echo ; Output it.
- 80/ FF26 : CE 02 01 ldx #in+1 ; Initiallize [sic] text index.
- 81/ FF29 : C6 01 ldab #1
- 82/ FF2B : 09 backspace: dex ; Back up text index.
- 83/ FF2C : 5A decb
- 84/ FF2D : 2B F2 bmi getline ; Beyond start of line, reinitialize.
- 85/ FF2F :
- 86/ FF2F : B6 D0 11 nextchar: ldaa kbd_cr ; Key ready?
- 87/ FF32 : 2A FB bpl nextchar ; Loop until ready.
- 88/ FF34 : B6 D0 10 ldaa kbd ; Load character. B7 should be '1'.
- 89/ FF37 : A7 00 staa ,x ; Add to text buffer.
- 90/ FF39 : 8D 79 bsr echo ; Display character.
- 91/ FF3B : 81 8D cmpa #$8d ; CR?
- 92/ FF3D : 26 D1 bne notcr ; No.
- 93/ FF3F :
- 94/ FF3F : ; Process an input line.
- 95/ FF3F :
- 96/ FF3F : CE 02 FF cr: ldx #in+256-1 ; Reset text index to in-1, +256 so that
- 97/ FF42 : ; 'inc inptr+1' will result in $0200.
- 98/ FF42 : DF 2E stx inptr
- 99/ FF44 : 4F clra ; For XAM mode. 0->B.
- 100/ FF45 :
- 101/ FF45 : 48 setblok: asl a ; Leaves $56 if setting BLOCK XAM mode.
- 102/ FF46 : 97 2B setmode: staa mode ; $00 = XAM, $BA = STOR, $56 = BLOK XAM.
- 103/ FF48 : 7C 00 2F blskip: inc inptr+1 ; Advance text index.
- 104/ FF4B : DE 2E nextitem: ldx inptr
- 105/ FF4D : A6 00 ldaa ,x ; Get character.
- 106/ FF4F : 81 8D cmpa #$8d ; CR?
- 107/ FF51 : 27 CE beq getline ; Yes, done this line.
- 108/ FF53 : 81 AE cmpa #$ae ; "."?
- 109/ FF55 : 27 EE beq setblok ; Set BLOCK XAM mode.
- 110/ FF57 : 23 EF bls blskip ; Skip delimiter.
- 111/ FF59 : 81 BA cmpa #$ba ; ":"?
- 112/ FF5B : 27 E9 beq setmode ; Yes, set STOR mode.
- 113/ FF5D : 81 D2 cmpa #$d2 ; "R"?
- 114/ FF5F : 27 5C beq run ; Yes, run user program.
- 115/ FF61 : 7F 00 29 clr l ; $00->L.
- 116/ FF64 : 7F 00 28 clr h ; and H.
- 117/ FF67 : DF 2C stx ysav ; Save Y for comparison.
- 118/ FF69 :
- 119/ FF69 : DE 2E nexthex: ldx inptr
- 120/ FF6B : A6 00 ldaa ,x ; Get character for hex test.
- AS V1.42 Beta [Bld 77] - source file monitor68.asm - page 3 - 7/18/2011 15:27:38
- 121/ FF6D : 88 B0 eora #$b0 ; Map digits to $0-9.
- 122/ FF6F : 81 09 cmpa #$09 ; Digit?
- 123/ FF71 : 23 06 bls dig ; Yes.
- 124/ FF73 : 8B 89 adda #$89 ; Map letter "A"-"F" to $FA-FF.
- 125/ FF75 : 81 F9 cmpa #$f9 ; Hex letter?
- 126/ FF77 : 23 15 bls nothex ; No, character not hex.
- 127/ FF79 :
- 128/ FF79 : 48 dig: asla ; Hex digit to MSD of A.
- 129/ FF7A : 48 asla
- 130/ FF7B : 48 asla
- 131/ FF7C : 48 asla
- 132/ FF7D :
- 133/ FF7D : C6 04 ldab #$04 ; Shift count.
- 134/ FF7F : 48 hexshift: asla ; Hex digit left, MSB to carry.
- 135/ FF80 : 79 00 29 rol l ; Rotate into LSD.
- 136/ FF83 : 79 00 28 rol h ; Rotate into MSD's.
- 137/ FF86 : 5A decb ; Done 4 shifts?
- 138/ FF87 : 26 F6 bne hexshift ; No, loop.
- 139/ FF89 :
- 140/ FF89 : 7C 00 2F inc inptr+1 ; Advance text index.
- 141/ FF8C : 20 DB bra nexthex ; Always taken. Check next character for hex.
- 142/ FF8E :
- 143/ FF8E : 9C 2C nothex: cpx ysav ; Check if L, H empty (no hex digits).
- 144/ FF90 : 27 8A beq escape ; Yes, generate ESC sequence.
- 145/ FF92 : 7D 00 2B tst mode ; Test MODE byte.
- 146/ FF95 : 2A 2A bpl notstor ; B6=0 for STOR, 1 for XAM and BLOCK XAM
- 147/ FF97 :
- 148/ FF97 : ; STOR mode
- 149/ FF97 : DE 26 ldx st
- 150/ FF99 : 96 29 ldaa l ; LSD's of hex data.
- 151/ FF9B : A7 00 staa ,x ; Store at current 'store index'.
- 152/ FF9D : 08 inx
- 153/ FF9E : DF 26 stx st
- 154/ FFA0 : 20 A9 tonextitem: bra nextitem ; Get next command item.
- 155/ FFA2 :
- 156/ FFA2 : 36 prbyte: psh a ; Save A for LSD.
- 157/ FFA3 : 44 lsra
- 158/ FFA4 : 44 lsra
- 159/ FFA5 : 44 lsra ; MSD to LSD position.
- 160/ FFA6 : 44 lsra
- 161/ FFA7 : 8D 01 bsr prhex ; Output hex digit.
- 162/ FFA9 : 32 pul a ; Restore A.
- 163/ FFAA : 84 0F prhex: anda #$0f ; Mask LSD for hex print.
- 164/ FFAC : 8A B0 oraa #$b0 ; Add "0".
- 165/ FFAE : 81 B9 cmpa #$b9 ; Digit?
- 166/ FFB0 : 23 02 bls echo ; Yes, output it.
- 167/ FFB2 : 8B 07 adda #$07 ; Add offset for letter.
- 168/ FFB4 : 7D D0 12 echo: tst dsp ; DA bit (B7) cleared yet?
- 169/ FFB7 : 2B FB bmi echo ; No, wait for display.
- 170/ FFB9 : B7 D0 12 staa dsp ; Output character. Sets DA.
- 171/ FFBC : 39 rts ; Return.
- 172/ FFBD :
- 173/ FFBD : DE 24 run: ldx xam
- 174/ FFBF : 6E 00 jmp ,x ; Run at current XAM index.
- 175/ FFC1 :
- 176/ FFC1 : 26 23 notstor: bne xamnext ; mode = $00 for XAM, $56 for BLOCK XAM.
- 177/ FFC3 :
- 178/ FFC3 : DE 28 ldx h ; Copy hex data to
- 179/ FFC5 : DF 26 stx st ; 'store index'.
- 180/ FFC7 : DF 24 stx xam ; And to 'XAM index'.
- AS V1.42 Beta [Bld 77] - source file monitor68.asm - page 4 - 7/18/2011 15:27:38
- 181/ FFC9 : 4F clra ; set Z flag to force following branch.
- 182/ FFCA :
- 183/ FFCA : 26 10 nxtprnt: bne prdata ; NE means no address to print.
- 184/ FFCC : 86 8D ldaa #$8d ; CR.
- 185/ FFCE : 8D E4 bsr echo ; Output it.
- 186/ FFD0 : 96 24 ldaa xam ; 'Examine index' high-order byte.
- 187/ FFD2 : 8D CE bsr prbyte ; Output it in hex format.
- 188/ FFD4 : 96 25 ldaa xam+1 ; Low-order 'Examine index' byte.
- 189/ FFD6 : 8D CA bsr prbyte ; Output it in hex format.
- 190/ FFD8 : 86 BA ldaa #$ba ; ":".
- 191/ FFDA : 8D D8 bsr echo ; Output it.
- 192/ FFDC :
- 193/ FFDC : 86 A0 prdata: ldaa #$a0 ; Blank.
- 194/ FFDE : 8D D4 bsr echo ; Output it.
- 195/ FFE0 :
- 196/ FFE0 : DE 24 ldx xam
- 197/ FFE2 : A6 00 ldaa ,x ; Get data byte at 'examine index'.
- 198/ FFE4 : 8D BC bsr prbyte ; Output it in hex format.
- 199/ FFE6 :
- 200/ FFE6 : 7F 00 2B xamnext: clr mode ; 0->MODE (XAM mode).
- 201/ FFE9 : DE 24 ldx xam ; Compare 'examine index' to hex data.
- 202/ FFEB : 9C 28 cpx h
- 203/ FFED : 27 B1 beq tonextitem ; Not less, so more data to output.
- 204/ FFEF : 08 inx
- 205/ FFF0 : DF 24 stx xam
- 206/ FFF2 : 96 25 ldaa xam+1 ; Check low-order 'examine index' byte
- 207/ FFF4 : 84 07 anda #$07 ; For MOD 8 = 0
- 208/ FFF6 : 20 D2 bra nxtprnt ; always taken
- 209/ FFF8 :
- 210/ FFF8 : org $fff8 ; vector table
- 211/ FFF8 : 00 00 fdb $0000 ; IRQ
- 212/ FFFA : 00 00 fdb $0000 ; SWI
- 213/ FFFC : F0 00 fdb $f000 ; NMI
- 214/ FFFE : FF 00 fdb $ff00 ; RESET
- 215/ 10000 :
- AS V1.42 Beta [Bld 77] - source file monitor68.asm - page 5 - 7/18/2011 15:27:38
- symbol table (* = unused):
- ------------------------
- *ARCHITECTURE : k8-unknown-linux - | BACKSPACE : FF2B C |
- *BIGENDIAN : 0 - | BLSKIP : FF48 C |
- *BRANCHEXT : 0 - | *CASESENSITIVE : 0 - |
- *CONSTPI : 3.141592653589793 - | *CR : FF3F C |
- *DATE : 7/18/2011 - | DIG : FF79 C |
- DSP : D012 - | DSP_CR : D013 - |
- ECHO : FFB4 C | ESCAPE : FF1C C |
- *FALSE : 0 - | *FULLPMMU : 1 - |
- GETLINE : FF21 C | H : 28 - |
- *HAS64 : 1 - | *HASDSP : 0 - |
- *HASFPU : 0 - | *HASPMMU : 0 - |
- HEXSHIFT : FF7F C | IN : 200 - |
- *INEXTMODE : 0 - | *INLWORDMODE : 0 - |
- *INMAXMODE : 0 - | INPTR : 2E - |
- *INSRCMODE : 0 - | *INSUPMODE : 0 - |
- KBD : D010 - | KBD_CR : D011 - |
- L : 29 - | *LISTON : 1 - |
- *MACEXP : 1 - | MODE : 2B - |
- *MOMCPU : 6800 - | *MOMCPUNAME : 6800 - |
- *NESTMAX : 100 - | NEXTCHAR : FF2F C |
- NEXTHEX : FF69 C | NEXTITEM : FF4B C |
- NOTCR : FF10 C | NOTHEX : FF8E C |
- NOTSTOR : FFC1 C | NXTPRNT : FFCA C |
- *PACKING : 0 - | *PADDING : 0 - |
- PRBYTE : FFA2 C | PRDATA : FFDC C |
- PRHEX : FFAA C | *RELAXED : 0 - |
- *RESET : FF00 C | RUN : FFBD C |
- SETBLOK : FF45 C | SETMODE : FF46 C |
- ST : 26 - | *TIME : 15:27:38 - |
- TONEXTITEM : FFA0 C | *TRUE : 1 - |
- *VERSION : 142F - | XAM : 24 - |
- XAMNEXT : FFE6 C | YSAV : 2C - |
- 64 symbols
- 30 unused symbols
- AS V1.42 Beta [Bld 77] - source file monitor68.asm - page 6 - 7/18/2011 15:27:38
- codepages:
- ----------
- STANDARD (0 changed characters)
- 0.01 seconds assembly time
- 215 lines source file
- 2 passes
- 0 errors
- 0 warnings
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement