eris2010

Documentation: http://frombelow.net/projects/eris2010/
Clone: git clone https://git.frombelow.net/eris2010.git
Log | Files | Refs | Submodules | README | LICENSE

wozmon.asm (7206B)


      1 ;;; Originally written by Steve Wozniak for the Apple I.
      2 ;;; This version is based on EWOZ Extended Woz Monitor by BigEd
      3 ;;; (https://gist.github.com/BigEd/2760560) with modifications
      4 ;;; from Gerd Beuster (gerd@frombelow.net).
      5 ;;;
      6 ;;; This version supports an additional command: S prints
      7 ;;; the stack pointer.
      8 
      9 
     10 ;;; Don't have to include OS stuff if we are part of the OS.
     11 .weak
     12 	WOZMON_EMBEDDED = false
     13 .endweak
     14 .if !WOZMON_EMBEDDED
     15 	.include "os.inc"
     16 .endif
     17 
     18 ACIA        = io.acia_base
     19 ACIA_CTRL   = ACIA+3
     20 ACIA_CMD    = ACIA+2
     21 ACIA_SR     = ACIA+1
     22 ACIA_DAT    = ACIA
     23 
     24 ;;; Input buffer located at end of RAM,
     25 ;;; below the RAM IRQ vector.
     26 IN          = os.irq_vector - 128          ;*Input buffer
     27 ;;; Use zero-page addresses at end of zero-page.
     28 ;;; Since OS and programs fill zero-page from bottom to
     29 ;;; top, this should be least destructive ...
     30 XAML        = $F8            ;*Index pointers
     31 XAMH        = $F9
     32 STL         = $FA
     33 STH         = $FB
     34 L           = $FC
     35 H           = $FD
     36 YSAV        = $FE
     37 MODE        = $FF
     38 
     39 RESET       cld             ;Clear decimal arithmetic mode.
     40             cli
     41         jsr io.init_acia
     42          #io.PRINTSNL "Welcome to WOZMON!"
     43 SOFTRESET   lda #$9B      ;* Auto escape.
     44 NOTCR
     45 .if SYMON
     46 	cmp #$88        ; Backspace in Symon
     47 .else
     48 	cmp #$DF        ; Backspace in terminal
     49 .endif
     50             beq BACKSPACE   ;Yes.
     51             cmp #$9B        ;ESC?
     52             beq ESCAPE      ;Yes.
     53             iny             ;Advance text index.
     54             bpl NEXTCHAR    ;Auto ESC if >127.
     55 ESCAPE      lda #$DC        ;"\"
     56             jsr ECHO        ;Output it.
     57 GETLINE  	#io.PRINTNL
     58             ldy #$01        ;Initialize text index.
     59 BACKSPACE   phx
     60 	phy
     61 	#term.CURSOR_BACK 2
     62 	lda #' '
     63 	jsr io.putc
     64 	jsr io.putc
     65 	#term.CURSOR_BACK 2
     66 	ply
     67 	plx
     68 	dey             ;Backup text index.
     69         bpl NEXTCHAR
     70 	ldy #$00     ;Beyond start of line, reinitialize.
     71 NEXTCHAR    lda ACIA_SR     ;*See if we got an incoming char
     72             and #$08        ;*Test bit 3
     73             beq NEXTCHAR    ;*Wait for character
     74             lda ACIA_DAT    ;*Load char
     75          cmp #$60      ;*Is it Lower case
     76          bmi   CONVERT      ;*Nope, just convert it
     77          and #$5F      ;*If lower case, convert to Upper case
     78 CONVERT     ora #$80        ;*Convert it to "ASCII Keyboard" Input
     79             sta IN,y        ;Add to text buffer.
     80             jsr ECHO        ;Display character.
     81             cmp #$8D        ;CR?
     82             bne NOTCR       ;No.
     83             ldy #$FF        ;Reset text index.
     84             lda #$00        ;For XAM mode.
     85             TAX             ;0->X.
     86 SETSTOR     asl a             ;Leaves $7B if setting STOR mode.
     87 SETMODE     sta MODE        ;$00 = XAM, $7B = STOR, $AE = BLOK XAM.
     88 BLSKIP      iny             ;Advance text index.
     89 NEXTITEM    lda IN,y        ;Get character.
     90             cmp #$8D        ;CR?
     91             beq GETLINE     ;Yes, done this line.
     92             cmp #$AE        ;"."?
     93             bcc BLSKIP      ;Skip delimiter.
     94             beq SETMODE     ;Set BLOCK XAM mode.
     95             cmp #$BA        ;":"?
     96             beq SETSTOR     ;Yes, set STOR mode.
     97          cmp #$D2        ;"R"?
     98         beq RUN         ;Yes, run user program.
     99 	cmp #$D3	;"S"?
    100 	beq STACK	;Yes, print stack pointer
    101             stx L           ;$00->L.
    102             stx H           ; and H.
    103             sty YSAV        ;Save Y for comparison.
    104 NEXTHEX     lda IN,y        ;Get character for hex test.
    105             eor #$B0        ;Map digits to $0-9.
    106             cmp #$0A        ;Digit?
    107             bcc DIG         ;Yes.
    108             adc #$88        ;Map letter "A"-"F" to $FA-FF.
    109             cmp #$FA        ;Hex letter?
    110             bcc NOTHEX      ;No, character not hex.
    111 DIG         asl a
    112             asl a             ;Hex digit to MSD of A.
    113             asl a
    114             asl a
    115             ldx #$04        ;Shift count.
    116 HEXSHIFT    asl a             ;Hex digit left MSB to carry.
    117             rol L           ;Rotate into LSD.
    118             rol H           ;Rotate into MSD's.
    119             dex             ;Done 4 shifts?
    120             bne HEXSHIFT    ;No, loop.
    121             iny             ;Advance text index.
    122             bne NEXTHEX     ;Always taken. Check next character for hex.
    123 NOTHEX      cpy YSAV        ;Check if L, H empty (no hex digits).
    124          bne NOESCAPE   ;* Branch out of range, had to improvise...
    125         jmp ESCAPE      ;Yes, generate ESC sequence.
    126 	;; Addition by gb
    127 STACK	#io.PRINTNL
    128 	tsx
    129 	txa
    130 	jsr io.puth
    131 	jmp GETLINE
    132 RUN         jsr ACTRUN      ;* jsr to the Address we want to run.
    133          jmp   SOFTRESET   ;* When returned for the program, reset EWOZ.
    134 ACTRUN      jmp (XAML)      ;Run at current XAM index.
    135 
    136 NOESCAPE    bit MODE        ;Test MODE byte.
    137             bvc NOTSTOR     ;B6=0 for STOR, 1 for XAM and BLOCK XAM
    138             lda L           ;LSD's of hex data.
    139             sta (STL,x)    ;Store at current "store index".
    140             inc STL         ;Increment store index.
    141             bne NEXTITEM    ;Get next item. (no carry).
    142             inc STH         ;Add carry to 'store index' high order.
    143 TONEXTITEM  jmp NEXTITEM    ;Get next command item.
    144 NOTSTOR     bmi XAMNEXT     ;B7=0 for XAM, 1 for BLOCK XAM.
    145             ldx #$02        ;Byte count.
    146 SETADR      lda L-1,x       ;Copy hex data to
    147             sta STL-1,x     ;"store index".
    148             sta XAML-1,x    ;And to "XAM index'.
    149             dex             ;Next of 2 bytes.
    150             bne SETADR      ;Loop unless X = 0.
    151 NXTPRNT     bne PRDATA      ;NE means no address to print.
    152 	phx
    153 	phy
    154 	#io.PRINTNL
    155 	ply
    156 	plx
    157             lda XAMH        ;'Examine index' high-order byte.
    158             jsr PRBYTE      ;Output it in hex format.
    159             lda XAML        ;Low-order "examine index" byte.
    160             jsr PRBYTE      ;Output it in hex format.
    161             lda #$BA        ;":".
    162             jsr ECHO        ;Output it.
    163 PRDATA      lda #$A0        ;Blank.
    164             jsr ECHO        ;Output it.
    165             lda (XAML,x)    ;Get data byte at 'examine index".
    166             jsr PRBYTE      ;Output it in hex format.
    167 XAMNEXT     stx MODE        ;0-> MODE (XAM mode).
    168             lda XAML
    169             cmp L           ;Compare 'examine index" to hex data.
    170             lda XAMH
    171             sbc H
    172             bcs TONEXTITEM  ;Not less, so no more data to output.
    173             inc XAML
    174             bne MOD8CHK     ;Increment 'examine index".
    175             inc XAMH
    176 MOD8CHK     lda XAML        ;Check low-order 'exainine index' byte
    177             and #$0F        ;For MOD 8=0 ** changed to $0F to get 16 values per row **
    178             bpl NXTPRNT     ;Always taken.
    179 PRBYTE      pha             ;Save A for LSD.
    180             lsr a
    181             lsr a
    182             lsr a             ;MSD to LSD position.
    183             lsr a
    184             jsr PRHEX       ;Output hex digit.
    185             pla             ;Restore A.
    186 PRHEX       and #$0F        ;Mask LSD for hex print.
    187             ora #$B0        ;Add "0".
    188             cmp #$BA        ;Digit?
    189             bcc ECHO        ;Yes, output it.
    190             adc #$06        ;Add offset for letter.
    191 ECHO        pha             ;*Save A
    192 	phx
    193 	phy
    194         and #$7F        ;*Change to "standard ASCII"
    195 	jsr io.putc
    196 	ply
    197 	plx
    198 	pla
    199             rts             ;*Done, over and out...