Advertisement
brouhaha

assembly listing for MC6800 monitor for Apple 1

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