0000- 105 .FI 0000- S 106 .DO VDU=41 0000- S 107 ; Building 6809 Monitor for Flex and Teletext VDU alternative configuration 0000- S 108 .TF Flex41.bin,BIN 0000- 110 .FI 0000- S 111 .DO VDU=80 0000- S 112 ; Building 6809 Monitor for Flex memory and 80-Column VDU 0000- S 113 .TF Flex80.bin,BIN 0000- 115 .FI 0000- 116 .FI 0000- 117 ; 0000- 118 ; ******************************************************** 0000- 119 ; F800- 120 MPROM .EQ $F800 ; Normal monitor position at top of memory 00E3- 121 MONDP .EQ BASE+$0300/256 ; Direct page for monitor 0000- 122 ; 0000- 123 ; VDU Configuration 0019- 124 ROWS .EQ 25 ; Number of rows on display. 0028- 125 COLS .EQ VDU&$F8 ; Number of characters per row, 40 or 80 0400- 126 PSIZE .EQ VDU&$F8/10*256 ; Size of display memory in total, $0400 (1K) or $0800 (2K) 000C- 127 PAGHI .EQ 12 ; Page address register, high byte 000E- 128 CURHI .EQ 14 ; Cursor address register, high byte 0000- 129 ; 0000- 130 .DO VDU&$F8=40 ; Location of memory that 40-Column (Teletext) VDU uses: E400- 131 VPAGE .EQ BASE+$400 ; Standard $0400 0000- 132 ; Flex $E400 0000- 133 ; Location of CRT controller on 40-column VDU card: E800- 134 CRTC .EQ BASE+$0800 ; Standard $0800 0000- 135 .FI ; Flex $E800 0000- 136 ; 0000- S 137 .DO VDU=80 ; Location of memory that 80-Column VDU uses: 0000- S 138 VPAGE .EQ BASE+$1000 ; Standard $1000 0000- S 139 ; Flex $F000 0000- S 140 ; Location of CRT controller on 80-column VDU card: 0000- S 141 CRTC .EQ BASE+$1840 ; Standard $1840 0000- 142 .FI ; Flex $E840 0000- 143 ; 0003- 144 WRPMSK .EQ PSIZE/256-1 ; Mask to wrap address within PSIZE, 3 (40-column) or 7 (80-column) 0000- 145 ; 0040- 146 DRIVE .EQ $40 ; Drive to bootstrap from, other drive is $80 EA00- 147 FLOPY .EQ BASE+$0A00 ; Location of floppy disc controller: 0000- 148 ; Standard $0A00 0000- 149 ; Flex $EA00 EA00- 150 FDCC .EQ FLOPY+0 ; Command register EA00- 151 FDCS .EQ FDCC ; Status register EA01- 152 FDCP .EQ FLOPY+1 ; Parameter register EA01- 153 FDCR .EQ FDCP ; Result register EA02- 154 FDRST .EQ FLOPY+2 ; Reset register EA04- 155 FDCD .EQ FLOPY+4 ; Data register 0000- 156 ; E980- 157 KVIA .EQ BASE+$0980 ; Location of Versatile Interface Adaptor E980- 158 KORB .EQ KVIA+$0 ; Output register B E980- 159 KIRB .EQ KORB ; Input register B E981- 160 KORA .EQ KVIA+$1 ; Output register A E981- 161 KIRA .EQ KORA ; Input register A E982- 162 KDDRB .EQ KVIA+$2 ; Data direction register B E983- 163 KDDRA .EQ KVIA+$3 ; Data direction register A E984- 164 KT1CL .EQ KVIA+$4 ; Timer 1 counter low E985- 165 KT1CH .EQ KVIA+$5 ; Timer 1 counter high E986- 166 KT1LL .EQ KVIA+$6 ; Timer 1 latch low E987- 167 KT1LH .EQ KVIA+$7 ; Timer 1 latch high E988- 168 KT2CL .EQ KVIA+$8 ; Timer 2 counter low E989- 169 KT2CH .EQ KVIA+$9 ; Timer 2 counter high E98A- 170 KSR .EQ KVIA+$A ; Shift register E98B- 171 KACR .EQ KVIA+$B ; Auxiliary control register E98C- 172 KPCR .EQ KVIA+$C ; Peripheral control register E98D- 173 KIFR .EQ KVIA+$D ; Interrupt flag register E98E- 174 KIER .EQ KVIA+$E ; Interrupt enable register E98F- 175 KORA2 .EQ KVIA+$F ; Input/output register A without hand shake 0000- 176 ; 0F00- 177 INTDEL .EQ 15*256 ; Delay for single instruction trace is 15 cycles 0040- 178 T1IFLG .EQ %01000000 ; Interrupt flag position for timer 1 0010- 179 CB1FLG .EQ %00010000 ; Interrupt flag position for keyboard strobe on CB1 0000- 180 ; 00EF- 181 IKPCR .EQ %11101111 ; Initial value for peripheral control register, 0000- 182 ; bit 0 CA1 control from printer, positive edge interrupt, 0000- 183 ; but not used in this monitor 0000- 184 ; bits 1-3 CA2 control to strobe printer, normally high 0000- 185 ; bit 4 CB1 control, negative edge keyboard interrupt 0000- 186 ; bits 5-7 CB2 control, cassette output initially set high 0000- 187 ; 00D0- 188 IKIER .EQ %11010000 ; Interrupt enable register control 0000- 189 ; bit 4 CB1 keyboard interrupt enable 0000- 190 ; bit 6 timer 1 interrupt enable 0000- 191 ; bit 7 set interrupts enabled 0000- 192 ; other enables not altered 0000- 193 ; 0002- 194 PSTRB .EQ %00000010 ; bit position in PCR of printer strobe, to toggle CA2 0020- 195 COPBIT .EQ %00100000 ; bit position in PCR of cassette output, to toggle CB2 0000- 196 ; 003F- 197 SWIOP .EQ $3F ; Software interrupt used for breakpoints 0000- 198 ; 0052- 199 BUFLEN .EQ 81+1 ; Buffer up to 80 characters from keyboard 0000- 200 ; 002A- 201 PROMPT .EQ '*' ; Monitor prompt 007F- 202 RUBCH .EQ $7F ; Keyboard code that does rubout operation 007F- 203 BSPACE .EQ $7F ; Code that backspaces VDU, also used to do rubout 000A- 204 LF .EQ $0A ; Linefeed 000D- 205 CR .EQ $0D ; Carriage return 0020- 206 SPACE .EQ $20 ; Blank space 002C- 207 COMMA .EQ ',' ; The comma symbol 002D- 208 MINUS .EQ '-' ; The minus symbol 000C- 209 FFEED .EQ $0C ; Code used as clear screen command 003B- 210 SEMIC .EQ ';' ; The semicolon symbol 0000- 211 ; 0010- 212 IRQ .EQ $10 0004- 213 ZERO .EQ $04 0000- 214 ; 0000- 215 ; Definitions of variables in page 03 / E3 0000- 216 ; ---------------------------------------- 0000- 217 ; E35B- 218 ISTACK .EQ BASE+$035B ; Stack pointer starts here E35B- 219 RTAB1 .EQ BASE+$035B ; RAM table 1 starts here 0000- 220 ; 0000- 221 ; This table is copied from ROM on start-up 0000- 222 ; E35B- 223 STACK .EQ BASE+$035B ; Position of stack pointer when empty E35D- 224 NTRACE .EQ BASE+$035D ; Number of instructions to trace before stopping E35F- 225 BSECHO .EQ BASE+$035F ; Character sent to backspace display E360- 226 ECHOF .EQ BASE+$0360 ; Keyboard buffer/echo control 0000- 227 ; bits 0-5 don't care 0000- 228 ; bit 6 echo console input to console output if set 0000- 229 ; bit 7 buffer input lines, allow rubout if set 0000- 230 ; E361- 231 PFLAG .EQ BASE+$0361 ; Printer control flag, echo console output to printer if nonzero E362- 232 PNEW .EQ BASE+$0362 ; This character not sent to printer E363- 233 DELCNT .EQ BASE+$0363 ; Non-zero delay count for cassette, controls baud rate E365- 234 COPADR .EQ BASE+$0365 ; Address for console output E367- 235 CINADR .EQ BASE+$0367 ; Address for console input E369- 236 CASOPA .EQ BASE+$0369 ; Address for cassette output E36B- 237 CASINA .EQ BASE+$036B ; Address for cassette input E36D- 238 PRINT1 .EQ BASE+$036D ; Address of printer output routine E36F- 239 FUNCTI .EQ BASE+$036F ; Address of VDU function table E371- 240 CMNDI .EQ BASE+$0371 ; Address of monitor command table E373- 241 IRQRTS .EQ BASE+$0373 ; Address to go to on timer 1 interrupt E375- 242 LINEPT .EQ BASE+$0375 ; Address of memory input line, 0 if none E377- 243 IRESV .EQ BASE+$0377 ; Address of reserved vector routine E379- 244 ISWI3 .EQ BASE+$0379 ; Address of SWI1 routine E37B- 245 ISWI2 .EQ BASE+$037B ; Address of SWI2 routine E37D- 246 IFIRQ .EQ BASE+$037D ; Address of FIRQ routine E37F- 247 IIRQ .EQ BASE+$037F ; Address of IRQ routine E381- 248 ISWI .EQ BASE+$0381 ; Address of SWI routine E383- 249 INMI .EQ BASE+$0383 ; Address of NMI routine E385- 250 OFFSET .EQ BASE+$0385 ; Cassette load offset 0000- 251 ; 0000- 252 ; General variables for monitor use 0000- 253 ; E387- 254 HEADST .EQ BASE+$0387 ; Static head pointer into line buffer E389- 255 HEADDY .EQ BASE+$0389 ; Dynamic head pointer into line buffer E38B- 256 TAIL .EQ BASE+$038B ; Tail pointer into line buffer E38D- 257 MSTACK .EQ BASE+$038D ; stack saved whilst memory interpreting E38F- 258 CROW .EQ BASE+$038F ; current row of cursor on display E390- 259 CCOL .EQ BASE+$0390 ; current column of cursor on display E391- 260 CPAGE .EQ BASE+$0391 ; current start of display page in memory E393- 261 MSAV .EQ BASE+$0393 ; Saved address for memory command E395- 262 GSAV .EQ BASE+$0395 ; Saved address for go command E397- 263 NAME .EQ BASE+$0397 ; Saved name for cassette input output E39D- 264 CSSTRT .EQ BASE+$039D ; Saved cassette output start address E39F- 265 CSEND .EQ BASE+$039F ; Saved cassette output end address E3A1- 266 ONLINE .EQ BASE+$03A1 ; flag set to zero when find or in input line E3A2- 267 LASTC .EQ BASE+$03A2 ; Saved last character from input line current E3A3- 268 CBREAK .EQ BASE+$03A3 ; Address of breakpoint, $FFFF if none E3A5- 269 NBREAK .EQ BASE+$03A5 ; number of breakpoints to ignore before stopping user E3A7- 270 CINST .EQ BASE+$03A7 ; user instruction at breakpoint address E3A8- 271 CTRACE .EQ BASE+$03A8 ; number of instructions left to trace before stopping user E3AA- 272 USRSTK .EQ BASE+$03AA ; Saved user-stack pointer when user halted E3AC- 273 TEMP .EQ BASE+$03AC ; Temporary storage E3AE- 274 BUFFER .EQ BASE+$03AE ; line input buffer 0000- 275 ; BASE+$03FF ; end of line input buffer 0000- 276 ; 0000- 277 ; Memory Maps 0000- 278 ; ----------- 0000- 279 ; 0000- 280 ; Original Acorn 0000- 281 ; $0000-$03FF Monitor System RAM (IC5,6) 0000- 282 ; $0400-$07FF 40-column Teletext video memory 0000- 283 ; $0800-$08FF 40-column Teletext 6845 CRTC 0000- 284 ;; $0900-$09FF 6522 VIA ($0980) 0000- 285 ; REGA b6-b0 printer output 0000- 286 ; b7 printer busy input 0000- 287 ; REGB b6-b0 keyboard ASCII input 0000- 288 ; b7 cassette input 0000- 289 ; CA1 input from printer acknowledge (not used) 0000- 290 ; CA2 output strobe to printer 0000- 291 ; CB1 input strobe from keyboard 0000- 292 ; CB2 output to cassette 0000- 293 ; Timer1 used to single step 0000- 294 ; Timer2 unused 0000- 295 ; $0A00-$0A7F 8271 floppy disk controller 0000- 296 ; $1000-$17FF 80-column VDU video memory 0000- 297 ; $1800-$187F 80-column 6845 CRTC ($1840) 0000- 298 ; $2000-$3FFF User RAM (8K) 0000- 299 ; $2000-$BFFF or User RAM (8K+32K) 0000- 300 ; $F800-$FFFF Monitor EPROM (IC4) 0000- 301 ; 0000- 302 ; Flex 0000- 303 ; $0000-$7FFF User RAM (32K) 0000- 304 ; $0000-$BFFF or User RAM (48K) 0000- 305 ; $C000-$DFFF FLEX System RAM (loaded from Disk) 0000- 306 ; $E000-$E3FF Monitor System RAM (IC5,6) 0000- 307 ; $E400-$E7FF 40-column Teletext Video memory 0000- 308 ; $E800-$E8FF 40-column Teletext 6845 CRTC 0000- 309 ; $E800-$E87F 80-column 6845 CRTC ($E840) 0000- 310 ; $E900-$E9FF 6522 VIA ($E980) 0000- 311 ; REGA b6-b0 printer output 0000- 312 ; b7 printer busy input 0000- 313 ; REGB b6-b0 keyboard ASCII input 0000- 314 ; b7 cassette input 0000- 315 ; CA1 input from printer acknowledge (not used) 0000- 316 ; CA2 output strobe to printer 0000- 317 ; CB1 input strobe from keyboard 0000- 318 ; CB2 output to cassette 0000- 319 ; Timer1 used to single step 0000- 320 ; Timer2 unused 0000- 321 ; $EA00-$EA7F 8271 floppy disk controller 0000- 322 ; $F000-$F7FF 80-column VDU video memory 0000- 323 ; $F800-$FFFF Monitor EPROM (IC4) 0000- 324 ; F800- 325 .OR MPROM F800- 326 ; F800- 327 ; ****** Hardware Reset Starts Here ****** F800- 328 ; F800-86 E3 329 ( 2) RESET: LDA #MONDP ; Set up direct page F802-1F 8B 330 ( 7) TFR A,DP F804- 331 .DP MONDP F804-8E FF 25 332 ( 3) LDX #PTAB1 ; ROM table start F807-CE E3 5B 333 ( 3) LDU #RTAB1 ; RAM table start F80A-A6 80 334 ( 7) RST1: LDA ,X+ ; Copy ROM F80C-A7 C0 335 ( 7) STA ,U+ ; to RAM F80E-8C FF 51 336 ( 4) CMPX #PTAB2 ; until end of table F811-26 F7 337 ( 3) BNE RST1 F813-10 DE 5B 338 ( 6) LDS LINEPT ; unless F852-26 03 390 ( 3) BNE MON1 ; memory input F854-17 01 CA 391 ( 9) LBSR CONOUT F857- 392 ; F857-B7 E3 A1 393 ( 5) MON1: STA >ONLINE ; Set no CR yet F85A-86 E3 394 ( 2) PARSE: LDA #MONDP F85C-1F 8B 395 ( 7) TFR A,DP ; Set direct page F85E- 396 .DP MONDP F85E-9E 75 397 ( 5) LDX