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