diff --git a/BIN/OD.S.txt b/BIN/OD.S.txt index c938ee38..676cfe9e 100644 --- a/BIN/OD.S.txt +++ b/BIN/OD.S.txt @@ -12,317 +12,281 @@ .DUMMY .OR ZPBIN ZS.START +ArgIndex .BS 1 +ArgPattern .BS 1 ZPPtr1 .BS 2 ZPBufPtr .BS 2 -ByteIndex .BS 1 -ArgCount .BS 1 -FileCount .BS 1 -bPause .BS 1 -bDummy .BS 1 -bStdout .BS 1 -ArgIndex .BS 1 -hBuf .BS 1 hFile .BS 1 +hBuf .BS 1 +char .BS 1 ByteCount .BS 3 -ZS.END .ED +bTemp .BS 1 +bDummy .BS 1 + +ZS.END .ED *-------------------------------------- * File Header (16 Bytes) *-------------------------------------- CS.START cld jmp (.1,x) - .DA #$61 6502,Level 1 (65c02) - .DA #1 BIN Layout Version 1 - .DA #S.PS.F.EVENT S.PS.F + .DA #$61 6502,Level 1 (65c02) + .DA #1 BIN Layout Version 1 + .DA #0 S.PS.F.EVENT .DA #0 - .DA CS.END-CS.START CS - .DA DS.END-DS.START DS - .DA #64 SS - .DA #ZS.END-ZS.START Zero Page Size + .DA CS.END-CS.START Code Size (without Constants) + .DA DS.END-DS.START Data Segment Size + .DA #16 Stack Size + .DA #ZS.END-ZS.START Zero Page Size .DA 0 *-------------------------------------- * Relocation Table *-------------------------------------- -.1 .DA CS.INIT - .DA CS.RUN - .DA CS.DOEVENT - .DA CS.QUIT -L.MSG.USAGE .DA MSG.USAGE -L.MSG.CRLF .DA MSG.CRLF -L.MSG.INIT .DA MSG.INIT -L.MSG.OFFSET .DA MSG.OFFSET -L.MSG.HEXBYTE .DA MSG.HEXBYTE - .DA 0 +.1 .DA CS.INIT + .DA CS.RUN + .DA CS.DOEVENT + .DA CS.QUIT +L.MSG.USAGE .DA MSG.USAGE +L.MSG.CRLF .DA MSG.CRLF +L.MSG.OFFSET .DA MSG.OFFSET +L.MSG.HEXBYTE .DA MSG.HEXBYTE + .DA 0 *-------------------------------------- -CS.INIT clc - rts +CS.INIT clc + rts *-------------------------------------- -CS.RUN -.1 stz bStdout - stz ByteCount - stz ByteCount+1 - stz ByteCount+2 - - inc ArgCount - lda ArgCount - >SYSCALL ArgV - bcs .7 +CS.RUN jsr CS.RUN.CheckArgs + bcs CS.RUN.LOOP.RTS - >STYA ZPPtr1 + stz ByteCount + stz ByteCount+1 + stz ByteCount+2 - lda (ZPPtr1) - cmp #'-' - bne .4 +CS.RUN.LOOP >SLEEP - ldy #1 - lda (ZPPtr1),y + lda hFile + >SYSCALL GetC + bcs .7 - ldx #OptionList.Cnt-1 + jsr CS.RUN.PRINTBYTE + bra CS.RUN.LOOP + +.7 cmp #MLI.E.EOF + bne .9 + + jsr CS.RUN.FINISHUP + +.8 lda #0 Exit with no Error + +.9 sec +CS.RUN.LOOP.RTS rts +*-------------------------------------- +CS.RUN.CheckArgs jsr CS.RUN.NextArg + bcs .4 + + lda (ZPPtr1) + cmp #'-' + beq .1 + +.11 lda hFile + bne .97 + + >LDYA ZPPtr1 + jsr CS.RUN.OPEN + bcs .9 + + sta hFile + bra CS.RUN.CheckArgs + +.1 ldy #1 + lda (ZPPtr1),y + + ldx #OptionList.Cnt-1 + +.2 cmp OptionList,x + beq .3 + + dex + bpl .2 + + bra .97 + +.3 txa + lsr + beq .98 + + tax + lda #$80 + sta bDummy-1,x + bra CS.RUN.CheckArgs -.2 cmp OptionList,x - beq .3 +.4 lda hFile + bne .80 - dex - bpl .2 - -.99 >PUSHW L.MSG.USAGE - >PUSHBI 0 - >SYSCALL PrintF - lda #E.SYN - sec -.9 rts - -.3 ldy OptionVars,x - lda #$80 - sta 0,y - bra .1 - -.4 inc FileCount - bra .1 scan for any other args - -.7 lda FileCount - beq .99 - - >LDYAI 256 - >SYSCALL GetMem - bcs .9 - - >STYA ZPBufPtr - stx hBuf + ldy #S.PS.hStdIn + lda (pPS),y + tax - ldy #S.PS.hStdOut - lda (pPS),y - - tax + lsr + bcs .97 - lsr - bcc CS.RUN.LOOP + lda Nod.Table.hFD-2,x + >SYSCALL GetMemPtr + >STYA ZPPtr1 + lda (ZPPtr1) + cmp #S.FD.T.PIPE + bne .97 - lda Nod.Table.hFD-2,x - >SYSCALL GetMemPtr - >STYA ZPPtr1 + ldy #S.PS.hStdIn + lda (pPS),y + sta hFile - lda (ZPPtr1) +.80 >LDYAI 256 + >SYSCALL GetMem + bcs .9 - beq CS.RUN.LOOP + >STYA ZPBufPtr + stx hBuf - cmp #S.FD.T.PIPE - beq CS.RUN.LOOP +* clc - lda #$ff - sta bStdout - - >PUSHW L.MSG.INIT - >PUSHBI 0 - >SYSCALL PrintF +.9 rts + +.97 lda #E.SYN + +.98 pha + >PUSHW L.MSG.USAGE + >PUSHBI 0 + >SYSCALL PrintF + pla + sec + rts *-------------------------------------- -CS.RUN.LOOP ldy #S.PS.hStdIn - lda (pPS),y - >SYSCALL FEOF - bcs .90 IO error +CS.RUN.NextArg inc ArgIndex + lda ArgIndex + >SYSCALL ArgV + bcs .9 - tay - bne .10 no char + >STYA ZPPtr1 - >SYSCALL GetChar - bcs .9 IO error - - cmp #$03 Ctrl-C - beq .9 Abort.... - - cmp #$13 Ctrl-S - bne .10 - - lda bPause - eor #$ff - sta bPause - bne CS.RUN.LOOP - -.10 lda bPause - bne CS.RUN.LOOP Pause... - -.11 lda hFile - bne .2 - -.1 inc ArgIndex - lda ArgIndex - >SYSCALL ArgV - bcs .99 No more arg...the end! - - >STYA ZPPtr1 - lda (ZPPtr1) - cmp #'-' - beq .1 An option, skip... - - >LDYA ZPPtr1 - jsr CS.RUN.OPEN -.90 bcs .9 - - sta hFile - -.2 lda hFile - >SYSCALL GetC - bcs .7 - - jsr CS.RUN.PRINTBYTE - - bra CS.RUN.LOOP - -.7 cmp #MLI.E.EOF - bne .9 - - jsr CS.RUN.CLOSE - jsr CS.RUN.FINISHUP - jmp CS.RUN.LOOP - -.99 lda #0 Exit with no Error -.9 sec - rts +.9 rts *-------------------------------------- -CS.RUN.OPEN >PUSHYA - >PUSHBI O.RDONLY+O.TEXT - >PUSHBI S.FI.T.TXT - >PUSHWZ Aux type - >SYSCALL FOpen - rts +CS.RUN.OPEN >PUSHYA + >PUSHBI O.RDONLY+O.TEXT + >PUSHBI S.FI.T.TXT + >PUSHWZ Aux type + >SYSCALL FOpen + bcs .9 + sta hFile +.9 rts *-------------------------------------- -CS.RUN.PRINTBYTE pha Char is in A - - lda ByteCount Divisible by 16 - and #$0f - pha - bne .2 - - >PUSHW L.MSG.OFFSET Print offset - lda ByteCount+2 - >PUSHA - lda ByteCount+1 - >PUSHA - lda ByteCount - >PUSHA - >PUSHBI 3 - >SYSCALL PrintF - -.2 ply Offset mod 16 - pla Character - pha - sta (ZPPtr1),y - - >PUSHW L.MSG.HEXBYTE - pla - >PUSHA - >PUSHBI 1 - >SYSCALL PrintF - -.6 lda ByteCount - and #$0f - cmp #$0f - bne .8 - - jsr CS.RUN.PRINTASCII - -.8 inc ByteCount - bne .9 - inc ByteCount+1 - bne .9 - inc ByteCount+2 - -.9 rts +CS.QUIT lda hFile + beq .1 + >SYSCALL FClose +.1 lda hBuf + beq .8 + >SYSCALL FreeMem +.8 clc + rts *-------------------------------------- -CS.RUN.PRINTASCII lda ByteCount - and #$0f - sta bDummy +CS.RUN.PRINTBYTE + pha Char is in A - lda #'>' - >SYSCALL PutChar + lda ByteCount Divisible by 16 + and #$0f + sta bTemp + bne .2 - ldy #$00 -.7 lda (ZPPtr1),y - phy - cmp #C.SPACE - bcs .8 - lda #'.' + >PUSHW L.MSG.OFFSET Print offset + lda ByteCount+2 + >PUSHA + lda ByteCount+1 + >PUSHA + lda ByteCount + >PUSHA + >PUSHBI 3 + >SYSCALL PrintF -.8 >SYSCALL PutChar - ply - iny - cpy bDummy - bne .7 +.2 ldy bTemp Offset mod 16 + pla Character + pha + sta (ZPBufPtr),y + + >PUSHW L.MSG.HEXBYTE + pla + >PUSHA + >PUSHBI 1 + >SYSCALL PrintF - lda #'<' - >SYSCALL PutChar +.6 inc ByteCount + bne .7 + inc ByteCount+1 + bne .7 + inc ByteCount+2 - lda #C.CR - >SYSCALL PutChar - lda bStdout - beq .9 - lda #C.LF - >SYSCALL PutChar +.7 lda bTemp + cmp #$0f + bne .9 -.9 rts + jsr CS.RUN.PRINTASCII + +.9 rts *-------------------------------------- -CS.RUN.FINISHUP lda ByteCount - and #$0f - bne .1 - rts -.1 pha - lda #' ' - >SYSCALL PutChar - lda #' ' - >SYSCALL PutChar - lda #' ' - >SYSCALL PutChar - pla - inc - cmp #$10 - bne .1 -.2 jsr CS.RUN.PRINTASCII - rts +CS.RUN.PRINTASCII + lda #'>' + >SYSCALL PutChar + + ldy #$00 +.7 lda (ZPBufPtr),y + phy + cmp #C.SPACE + bcs .8 + lda #'.' + +.8 >SYSCALL PutChar + ply + cpy bTemp + beq .85 + iny + bra .7 + +.85 lda #'<' + >SYSCALL PutChar + + lda #C.CR + >SYSCALL PutChar + lda #C.LF + >SYSCALL PutChar +.9 rts *-------------------------------------- -CS.QUIT lda hBuf - beq CS.RUN.CLOSE - >SYSCALL FreeMem - -CS.RUN.CLOSE lda hFile - beq .8 - - stz hFile - - >SYSCALL FClose -.8 clc - rts +CS.RUN.FINISHUP + lda ByteCount + and #$0f + bne .1 + rts +.1 pha + lda #' ' + >SYSCALL PutChar + lda #' ' + >SYSCALL PutChar + lda #' ' + >SYSCALL PutChar + pla + inc + cmp #$10 + bne .1 +.2 jsr CS.RUN.PRINTASCII + rts *-------------------------------------- -CS.DOEVENT sec - rts +CS.DOEVENT sec + rts *-------------------------------------- CS.END *-------------------------------------- OptionList .AS "x" OptionList.Cnt .EQ *-OptionList -OptionVars .DA #bDummy *-------------------------------------- -MSG.USAGE .AS "Usage : CAT File1 [File2...]" +MSG.USAGE .AS "Usage : OD or CMD|OD" MSG.CRLF .AZ "\r\n" -MSG.INIT .AZ "\e[?7h" Enable Line Wrap MSG.OFFSET .AZ "%h%h%h " MSG.HEXBYTE .AZ "%h " *--------------------------------------