eris2010

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

wozmon.asm (7077B)


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