diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c166d..27e5c17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ Version 0.8 =========== +- setup improvements, more settings - bootctl boot parameters for choosing 40/80 columns and c64mode - setup improvements, now saves settings - added assembler.128 diff --git a/ROADMAP.md b/ROADMAP.md index 1812388..e3de69a 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,11 +1,19 @@ -cpm+ boot customizer: - - selected drive - - shell ($a0a2) - - boot msg ($8a73) - - foreground ($8a65) - - background ($8a69) - - border ($8a6d) - - searchpath ($96e8) - - drive ($96af) - - user ($96b0) + +BOOT: +* autoboot on c64 is broken (shell should run configured program) + +KMON: +* `o` - old command, load and edit. perhaps `e` or `l` +* make `r!` work by running sjdos +* get command line args +* batch files get stuck (64 mode only) + +PIP: +* hex mode (/x) +* info mode (/i) - show only load address and length + +CP/M +* boot customizer +* installer + diff --git a/boot/autostart64.128.o b/boot/autostart64.128.o index a55e723..61f89a2 100644 Binary files a/boot/autostart64.128.o and b/boot/autostart64.128.o differ diff --git a/boot/autostart64.o b/boot/autostart64.o index de3a060..a98c001 100644 Binary files a/boot/autostart64.o and b/boot/autostart64.o differ diff --git a/boot/bootsect.128.o b/boot/bootsect.128.o index b30dc7d..50d86d4 100644 Binary files a/boot/bootsect.128.o and b/boot/bootsect.128.o differ diff --git a/c/setup b/c/setup index 3459d50..9836898 100644 Binary files a/c/setup and b/c/setup differ diff --git a/docs/drivers.md b/docs/drivers.md index c302fef..1695468 100644 --- a/docs/drivers.md +++ b/docs/drivers.md @@ -1,6 +1,7 @@ - -dos5.1 (858) +kmon $0801- +smon $9519-$9fff editor64 $c000-$c64b (1611) -hiloader64 (812) -smon $9519-$9fff +hiloader64 $c800- (812) +dos5.1 $cc00-$cfff (858) ieee +sweet16 diff --git a/install.sh b/install.sh index 3feb4f7..dc49221 100755 --- a/install.sh +++ b/install.sh @@ -22,6 +22,7 @@ c1541 $DISKIMG -write c/setup c1541 $DISKIMG -write s/empty '================' c1541 $DISKIMG -write s/startup,s c1541 $DISKIMG -write s/issue,s +c1541 $DISKIMG -write s/ucl.dat c1541 $DISKIMG -write s/keys c1541 $DISKIMG -write s/empty '=-demos--------=' @@ -35,13 +36,13 @@ do c1541 $DISKIMG -write "$i" `basename "$i" .prg` # >/dev/null done -c1541 $DISKIMG -write s/empty '=-extras 1541---=' +c1541 $DISKIMG -write s/empty '=-extras 1541--=' for i in c1541/* do c1541 $DISKIMG -write "$i" # >/dev/null done -c1541 $DISKIMG -write s/empty '=-extras 1571---=' +c1541 $DISKIMG -write s/empty '=-extras 1571--=' if [[ "$DISKIMG" =~ ".d64" ]] ; then exit; fi for i in c1571/* @@ -49,7 +50,7 @@ do c1541 "$DISKIMG" -write "$i" # >/dev/null done -c1541 $DISKIMG -write s/empty '=-extras 1581---=' +c1541 $DISKIMG -write s/empty '=-extras 1581--=' if [[ "$DISKIMG" =~ ".d71" ]] ; then exit; fi for i in c1581/* @@ -57,5 +58,5 @@ do c1541 "$DISKIMG" -write "$i" # >/dev/null done -c1541 $DISKIMG -write s/empty '=-user files----=' +c1541 $DISKIMG -write s/empty '=-user files---=' diff --git a/install_boot.sh b/install_boot.sh new file mode 100755 index 0000000..f7505a8 --- /dev/null +++ b/install_boot.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +DISKIMG=$1 + +c1541 $DISKIMG -bwrite boot/bootsect.128 1 0 -bwrite boot/autostart64.128 1 1 +c1541 $DISKIMG -@ "b-a 8 1 0" -@ "b-a 8 1 1" -write c/setup diff --git a/run64.d81 b/run64.d81 index 83c403a..53d6351 100644 Binary files a/run64.d81 and b/run64.d81 differ diff --git a/s/issue,s b/s/issue,s index f995c72..4697346 100644 --- a/s/issue,s +++ b/s/issue,s @@ -1,9 +1,7 @@ -Another good night not to sleep in a eucalyptus tree. +Q: How much does it cost to ride the Unibus? +A: 2 bits. -There are three infallible ways of pleasing an author, and the three form a -rising scale of compliment: 1, to tell him you have read one of his books; 2, -to tell him you have read all of his books; 3, to ask him to let you read the -manuscript of his forthcoming book. No. 1 admits you to his respect; No. 2 -admits you to his admiration; No. 3 carries you clear into his heart. +Training is everything. The peach was once a bitter almond; cauliflower is +nothing but cabbage with a college education. -- Mark Twain, "Pudd'nhead Wilson's Calendar" diff --git a/s/keys b/s/keys new file mode 100644 index 0000000..854045f Binary files /dev/null and b/s/keys differ diff --git a/s/ucl.dat b/s/ucl.dat new file mode 100644 index 0000000..f2dc68c Binary files /dev/null and b/s/ucl.dat differ diff --git a/tools/README.md b/tools/README.md index 6b85ee7..16cddd8 100644 --- a/tools/README.md +++ b/tools/README.md @@ -5,17 +5,22 @@ This directory contains a number of tools written specifically for run64. They include: 1. [kmon](../docs/kmon.md) - command line interpreter -1. pip - peripheral interchange program +1. [pip](../docs/pip.md) - file maintainance utility 1. patch64 - copy ROMs to RAM and apply patches, so it will run 1. patch128 - run c64 OS in c128 mode (broken) # To do + +## kmon 1. kmon run batch files 1. kmon startup batch file +1. kmon aliases 1. kmon n(ew) command 1. kmon o(ld) command 1. kmon m(emory) command 1. kmon c(hdir) command + +## pip 1. pip CLI options ✓ 1. pip file copying 1. pip ASCII/ANSI mode ✓ diff --git a/tools/core.s b/tools/core.s index e69de29..cf7b0dc 100644 --- a/tools/core.s +++ b/tools/core.s @@ -0,0 +1,356 @@ +; ----------------------------------------------------------------------------- +; main loop +STRT: jsr CRLF + + ; print current drive and prompt + lda FA + jsr WRTWO +; lda STATUS +; jsr WRTWO + msg prompt + + ; read one line of input into BUF + ldx #0 + +SMOVE: stx CHRPNT + jsr CHRIN + tay + lda STATUS + beq @ok1 + jsr CLRCHN + lda #0 + sta STATUS +@ok1: ldx CHRPNT + tya + sta BUF,X + inx + CPX #ENDIN-BUF ; error if buffer is full + BCS ERROR + cmp #10 ; convert lf to cr + bne @sm1 + lda #13 +@sm1: cmp #13 ; keep reading until CR + bne SMOVE + LDA #0 ; null-terminate input buffer + STA BUF-1,X ; (replacing the CR) + + ; execute BUF +STRT2: + LDA #0 + STA CHRPNT + stx COUNT + dec COUNT + beq STRT ; repeat if buffer is empty + +ST1: JSR GETCHR ; get a character from the buffer + BEQ STRT ; start over if buffer is empty + CMP #$20 ; skip leading spaces + BEQ ST1 + +S0: LDX #KEYTOP-KEYW ; loop through valid command characters +S1: CMP KEYW,X ; see if input character matches + BEQ S2 ; command matched, dispatch it + DEX ; no match, check next command + BPL S1 ; keep trying until we've checked them all + ; then fall through to error handler +; ----------------------------------------------------------------------------- +; handle error +ERROR: + LDY #MSG3-MSGBAS ; display "?" to indicate error and go to new line + JSR SNDMSG + JSR CLRCHN + JMP STRT ; back to main loop + +; ----------------------------------------------------------------------------- +; dispatch command +S2: + CPX #KEYTOP-KEYW-3 ; last 3 commands in table are load/save/validate + BCS LSV ; which are handled by the same subroutine + CPX #KEYTOP-KEYW-7 ; next 4 commands are base conversions + BCS CNVLNK ; which are handled by the same subroutine + TXA ; remaining commands dispatch through vector table + ASL A ; multiply index of command by 2 + TAX ; since table contains 2-byte addresses + LDA KADDR+1,X ; push address from vector table onto stack + PHA ; so that the RTS from GETPAR will jump there + LDA KADDR,X + PHA +; JMP GETPAR ; get the first parameter for the command + RTS +LSV: STA SAVY ; handle load/save/validate + JMP LD +CNVLNK: JMP CONVRT ; handle base conversion + +; ----------------------------------------------------------------------------- +; read parameters +RDPAR: DEC CHRPNT ; back up one char +GETPAR: JSR RDVAL ; read the value + BCS GTERR ; carry set indicates error + JSR GOTCHR ; check previous character + BNE CKTERM ; if it's not null, check if it's a valid separator + DEC CHRPNT ; back up one char + LDA DIGCNT ; get number of digits read + BNE GETGOT ; found some digits + BEQ GTNIL ; didn't find any digits +CKTERM: CMP #$20 ; space or comma are valid separators + BEQ GETGOT ; anything else is an error + CMP #',' + BEQ GETGOT +GTERR: PLA ; encountered error + PLA ; get rid of command vector pushed on stack + JMP ERROR ; handle error +GTNIL: SEC ; set carry to indicate no parameter found + .BYTE $24 ; BIT ZP opcode consumes next byte (CLC) +GETGOT: CLC ; clear carry to indicate paremeter returned + LDA DIGCNT ; return number of digits in A + RTS ; return to address pushed from vector table + +; ----------------------------------------------------------------------------- +; read a value in the specified base +RDVAL: LDA #0 ; clear temp + STA TMP0 + STA TMP0+1 + STA DIGCNT ; clear digit counter + TXA ; save X and Y + PHA + TYA + PHA +RDVMOR: JSR GETCHR ; get next character from input buffer + BEQ RDNILK ; null at end of buffer + CMP #$20 ; skip spaces + BEQ RDVMOR + LDX #3 ; check numeric base [$+&%] +GNMODE: CMP HIKEY,X + BEQ GOTMOD ; got a match, set up base + DEX + BPL GNMODE ; check next base + INX ; default to hex + DEC CHRPNT ; back up one character +GOTMOD: LDY MODTAB,X ; get base value + LDA LENTAB,X ; get bits per digit + STA NUMBIT ; store bits per digit +NUDIG: JSR GETCHR ; get next char in A +RDNILK: BEQ RDNIL ; end of number if no more characters + SEC + SBC #$30 ; subtract ascii value of 0 to get numeric value + BCC RDNIL ; end of number if character was less than 0 + CMP #$0A + BCC DIGMOR ; not a hex digit if less than A + SBC #$07 ; 7 chars between ascii 9 and A, so subtract 7 + CMP #$10 ; end of number if char is greater than F + BCS RDNIL +DIGMOR: STA INDIG ; store the digit + CPY INDIG ; compare base with the digit + BCC RDERR ; error if the digit >= the base + BEQ RDERR + INC DIGCNT ; increment the number of digits + CPY #10 + BNE NODECM ; skip the next part if not using base 10 + LDX #1 +DECLP1: LDA TMP0,X ; stash the previous 16-bit value for later use + STA STASH,X + DEX + BPL DECLP1 +NODECM: LDX NUMBIT ; number of bits to shift +TIMES2: ASL TMP0 ; shift 16-bit value by specified number of bits + ROL TMP0+1 + BCS RDERR ; error if we overflowed 16 bits + DEX + BNE TIMES2 ; shift remaining bits + CPY #10 + BNE NODEC2 ; skip the next part if not using base 10 + ASL STASH ; shift the previous 16-bit value one bit left + ROL STASH+1 + BCS RDERR ; error if we overflowed 16 bits + LDA STASH ; add shifted previous value to current value + ADC TMP0 + STA TMP0 + LDA STASH+1 + ADC TMP0+1 + STA TMP0+1 + BCS RDERR ; error if we overflowed 16 bits +NODEC2: CLC + LDA INDIG ; load current digit + ADC TMP0 ; add current digit to low byte + STA TMP0 ; and store result back in low byte + TXA ; A=0 + ADC TMP0+1 ; add carry to high byte + STA TMP0+1 ; and store result back in high byte + BCC NUDIG ; get next digit if we didn't overflow +RDERR: SEC ; set carry to indicate error + .BYTE $24 ; BIT ZP opcode consumes next byte (CLC) +RDNIL: CLC ; clear carry to indicate success + STY NUMBIT ; save base of number + PLA ; restore X and Y + TAY + PLA + TAX + LDA DIGCNT ; return number of digits in A + RTS + +; ----------------------------------------------------------------------------- +; copy TMP0 to TMP2 +COPY12: LDA TMP0 ; low byte + STA TMP2 + LDA TMP0+1 ; high byte + STA TMP2+1 + RTS + +; ----------------------------------------------------------------------------- +; copy TMP0 to PC +COPY1P: BCS CPY1PX ; do nothing if parameter is empty + LDA TMP0 ; copy low byte + LDY TMP0+1 ; copy high byte + STA PCL + STY PCH +CPY1PX: RTS + +; ----------------------------------------------------------------------------- +; convert base [$+&%] +CONVRT: JSR RDPAR ; read a parameter +CONVRT1: + JSR FRESH ; output character + LDA #'"' + JSR CHROUT + LDA TMP0 + JSR CHROUT + LDA TMP1 + JSR CHROUT + LDA #'"' + JSR CHROUT + + JSR FRESH ; next line and clear + LDA #'$' ; output $ sigil for hex + JSR CHROUT + LDA TMP0 ; load the 16-bit value entered + LDX TMP0+1 + JSR WRADDR ; print it in 4 hex digits + JSR FRESH + LDA #'+' ; output + sigil for decimal + JSR CHROUT + JSR CVTDEC ; convert to BCD using hardware mode + LDA #0 ; clear digit counter + LDX #6 ; max digits + 1 + LDY #3 ; bits per digit - 1 + JSR NMPRNT ; print result without leading zeros + JSR FRESH ; next line and clear + LDA #'&' ; print & sigil for octal + JSR CHROUT + LDA #0 ; clear digit counter + LDX #8 ; max digits + 1 + LDY #2 ; bits per digit - 1 + JSR PRINUM ; output number + JSR FRESH ; next line and clear + LDA #'%' ; print % sigil for binary + JSR CHROUT + LDA #0 ; clear digit counter + LDX #$18 ; max digits + 1 + LDY #0 ; bits per digit - 1 + JSR PRINUM ; output number + + JSR FRESH ; next line and clear + + LDA #'#' ; print % sigil for binary + JSR CHROUT + lda TMP0 ; 1st charaster + and #$1F + ora #$40 + jsr CHROUT + + lda TMP1 ; 2nd character + and #$03 + sta T1 + + lda TMP0 + asl + rol T1 + asl + rol T1 + asl + rol T1 + lda T1 + + ldx TMP1 ; + cpx #$c6 + beq @cvt3 ; it is a number + + ora #$40 + jsr CHROUT + + lda TMP1 ; 3rd character + bmi @cvt5 +@cvt4: ; it is a letter + lsr + lsr + and #$1f + ora #$40 + bne @cvt9 ; allways +@cvt5: ; it is a digit + lsr + lsr +@cvt3: + and #$0f + ora #$30 +@cvt9: + jsr CHROUT + JMP STRT ; back to mainloop + +; ----------------------------------------------------------------------------- +; convert binary to BCD + +CVTDEC: JSR COPY12 ; copy value from TMP0 to TMP2 + LDA #0 + LDX #2 ; clear 3 bytes in work buffer +DECML1: STA U0AA0,X + DEX + BPL DECML1 + LDY #16 ; 16 bits in input + PHP ; save status register + SEI ; make sure no interrupts occur with BCD enabled + SED +DECML2: ASL TMP2 ; rotate bytes out of input low byte + ROL TMP2+1 ; .. into high byte and carry bit + LDX #2 ; process 3 bytes +DECDBL: LDA U0AA0,X ; load current value of byte + ADC U0AA0,X ; add it to itself plus the carry bit + STA U0AA0,X ; store it back in the same location + DEX ; decrement byte counter + BPL DECDBL ; loop until all bytes processed + DEY ; decrement bit counter + BNE DECML2 ; loop until all bits processed + PLP ; restore processor status + RTS + +; load the input value and fall through to print it +PRINUM: PHA ; save accumulator + LDA TMP0 ; copy input low byte to work buffer + STA U0AA0+2 + LDA TMP0+1 ; copy input high byte to work buffer + STA U0AA0+1 + LDA #0 ; clear overflow byte in work buffer + STA U0AA0 + PLA ; restore accumulator + +; print number in specified base without leading zeros +NMPRNT: STA DIGCNT ; number of digits in accumulator + STY NUMBIT ; bits per digit passed in Y register +DIGOUT: LDY NUMBIT ; get bits to process + LDA #0 ; clear accumulator +ROLBIT: ASL U0AA0+2 ; shift bits out of low byte + ROL U0AA0+1 ; ... into high byte + ROL U0AA0 ; ... into overflow byte + ROL A ; ... into accumulator + DEY ; decrement bit counter + BPL ROLBIT ; loop until all bits processed + TAY ; check whether accumulator is 0 + BNE NZERO ; if not, print it + CPX #1 ; have we output the max number of digits? + BEQ NZERO ; if not, print it + LDY DIGCNT ; how many digits have we output? + BEQ ZERSUP ; skip output if digit is 0 +NZERO: INC DIGCNT ; increment digit counter + ORA #$30 ; add numeric value to ascii '0' to get ascii char + JSR CHROUT ; output character +ZERSUP: DEX ; decrement number of leading zeros + BNE DIGOUT ; next digit + RTS diff --git a/tools/kmon.128 b/tools/kmon.128 index de61123..e15240d 100644 Binary files a/tools/kmon.128 and b/tools/kmon.128 differ diff --git a/tools/kmon.64 b/tools/kmon.64 index 5f7b4a1..b7b1334 100644 Binary files a/tools/kmon.64 and b/tools/kmon.64 differ diff --git a/tools/kmon.s b/tools/kmon.s index 38ff961..87ae213 100644 --- a/tools/kmon.s +++ b/tools/kmon.s @@ -54,8 +54,8 @@ SUPER: jsr CRLF jmp kmon -; JSR CRLF - LDA LINKAD ; set BRK vector + ; set BRK vector + LDA LINKAD STA IBRK LDA LINKAD+1 STA IBRK+1 @@ -105,90 +105,7 @@ kmon: @nofast: .endif -; ----------------------------------------------------------------------------- -; main loop -STRT: jsr CRLF - - ; print current drive and prompt - lda FA - jsr WRTWO -; lda STATUS -; jsr WRTWO - msg prompt - - ; read one line of input into BUF - ldx #0 - -SMOVE: stx CHRPNT - jsr CHRIN - tay - lda STATUS - beq @ok1 - jsr CLRCHN - lda #0 - sta STATUS -@ok1: ldx CHRPNT - tya - sta BUF,X - inx - CPX #ENDIN-BUF ; error if buffer is full - BCS ERROR - cmp #10 ; convert lf to cr - bne @sm1 - lda #13 -@sm1: cmp #13 ; keep reading until CR - bne SMOVE - LDA #0 ; null-terminate input buffer - STA BUF-1,X ; (replacing the CR) - - ; execute BUF -STRT2: - LDA #0 - STA CHRPNT - stx COUNT - dec COUNT - beq STRT ; repeat if buffer is empty - -ST1: JSR GETCHR ; get a character from the buffer - BEQ STRT ; start over if buffer is empty - CMP #$20 ; skip leading spaces - BEQ ST1 - -S0: LDX #KEYTOP-KEYW ; loop through valid command characters -S1: CMP KEYW,X ; see if input character matches - BEQ S2 ; command matched, dispatch it - DEX ; no match, check next command - BPL S1 ; keep trying until we've checked them all - ; then fall through to error handler -; ----------------------------------------------------------------------------- -; handle error -ERROR: - LDY #MSG3-MSGBAS ; display "?" to indicate error and go to new line - JSR SNDMSG -; JSR STATUS -; JSR WRTWO - JSR CLRCHN - JMP STRT ; back to main loop - -; ----------------------------------------------------------------------------- -; dispatch command -S2: - CPX #KEYTOP-KEYW-3 ; last 3 commands in table are load/save/validate - BCS LSV ; which are handled by the same subroutine - CPX #KEYTOP-KEYW-7 ; next 4 commands are base conversions - BCS CNVLNK ; which are handled by the same subroutine - TXA ; remaining commands dispatch through vector table - ASL A ; multiply index of command by 2 - TAX ; since table contains 2-byte addresses - LDA KADDR+1,X ; push address from vector table onto stack - PHA ; so that the RTS from GETPAR will jump there - LDA KADDR,X - PHA -; JMP GETPAR ; get the first parameter for the command - RTS -LSV: STA SAVY ; handle load/save/validate - JMP LD -CNVLNK: JMP CONVRT ; handle base conversion +.include "core.s" ; ----------------------------------------------------------------------------- ; exit monitor [X] @@ -203,15 +120,15 @@ EXIT: ;SAVX: .res 1 ; 1 byte temp storage, often to save X register ;SAVY: .res 1 ; 1 byte temp storage, often to save Y register -DIGCNT: .res 1 ; digit count -INDIG: .res 1 ; numeric value of single digit -NUMBIT: .res 1 ; numeric base of input -STASH: .res 2 ; 2-byte temp storage -U0AA0: .res 10 ; work buffer +DIGCNT: .res 1 ; digit count +INDIG: .res 1 ; numeric value of single digit +NUMBIT: .res 1 ; numeric base of input +STASH: .res 2 ; 2-byte temp storage +U0AA0: .res 10 ; work buffer U0AAE =* ; end of work buffer -STAGE: .res 30 ; staging buffer for filename, search, etc. +STAGE: .res 30 ; staging buffer for filename, search, etc. ESTAGE =* ; end of staging buffer -STORE: .res 2 ; 2-byte temp storage +STORE: .res 2 ; 2-byte temp storage ;CHRPNT: .res 1 ; current position in input buffer PCH: .res 1 ; program counter high byte @@ -222,204 +139,7 @@ XR: .res 1 ; X register YR: .res 1 ; Y register SP: .res 1 ; stack pointer - -; ----------------------------------------------------------------------------- -; load, save, or verify [LSV] -LD: LDY #1 ; default to reading from tape, device #1 - STY FA - STY SA ; default to secondary address #1 - DEY - STY FNLEN ; start with an empty filename - STY STATUS ; clear status - LDA #>STAGE ; set filename pointer to staging buffer - STA FNADR+1 - LDA #= the base - BEQ RDERR - INC DIGCNT ; increment the number of digits - CPY #10 - BNE NODECM ; skip the next part if not using base 10 - LDX #1 -DECLP1: LDA TMP0,X ; stash the previous 16-bit value for later use - STA STASH,X - DEX - BPL DECLP1 -NODECM: LDX NUMBIT ; number of bits to shift -TIMES2: ASL TMP0 ; shift 16-bit value by specified number of bits - ROL TMP0+1 - BCS RDERR ; error if we overflowed 16 bits - DEX - BNE TIMES2 ; shift remaining bits - CPY #10 - BNE NODEC2 ; skip the next part if not using base 10 - ASL STASH ; shift the previous 16-bit value one bit left - ROL STASH+1 - BCS RDERR ; error if we overflowed 16 bits - LDA STASH ; add shifted previous value to current value - ADC TMP0 - STA TMP0 - LDA STASH+1 - ADC TMP0+1 - STA TMP0+1 - BCS RDERR ; error if we overflowed 16 bits -NODEC2: CLC - LDA INDIG ; load current digit - ADC TMP0 ; add current digit to low byte - STA TMP0 ; and store result back in low byte - TXA ; A=0 - ADC TMP0+1 ; add carry to high byte - STA TMP0+1 ; and store result back in high byte - BCC NUDIG ; get next digit if we didn't overflow -RDERR: SEC ; set carry to indicate error - .BYTE $24 ; BIT ZP opcode consumes next byte (CLC) -RDNIL: CLC ; clear carry to indicate success - STY NUMBIT ; save base of number - PLA ; restore X and Y - TAY - PLA - TAX - LDA DIGCNT ; return number of digits in A - RTS - -; ----------------------------------------------------------------------------- -; copy TMP0 to TMP2 -COPY12: LDA TMP0 ; low byte - STA TMP2 - LDA TMP0+1 ; high byte - STA TMP2+1 - RTS - -; ----------------------------------------------------------------------------- -; copy TMP0 to PC -COPY1P: BCS CPY1PX ; do nothing if parameter is empty - LDA TMP0 ; copy low byte - LDY TMP0+1 ; copy high byte - STA PCL - STY PCH -CPY1PX: RTS +.include "dos.s" ; ----------------------------------------------------------------------------- ; new [N] set memory bounds and perform NEW @@ -481,7 +201,6 @@ JSUB: JSR GETPAR PHP ; push processor status on stack PLA ; pull processor status into A STA SR ; save processor status to memory -; JMP DSPLYR ; display registers JMP STRT ; ----------------------------------------------------------------------------- @@ -567,268 +286,6 @@ TRIGRAM: jsr TRIGRAM_IN JMP CONVRT1 -; ----------------------------------------------------------------------------- -; convert base [$+&%] -CONVRT: JSR RDPAR ; read a parameter -CONVRT1: - JSR FRESH ; output character - LDA #'"' - JSR CHROUT - LDA TMP0 - JSR CHROUT - LDA TMP1 - JSR CHROUT - LDA #'"' - JSR CHROUT - - JSR FRESH ; next line and clear - LDA #'$' ; output $ sigil for hex - JSR CHROUT - LDA TMP0 ; load the 16-bit value entered - LDX TMP0+1 - JSR WRADDR ; print it in 4 hex digits - JSR FRESH - LDA #'+' ; output + sigil for decimal - JSR CHROUT - JSR CVTDEC ; convert to BCD using hardware mode - LDA #0 ; clear digit counter - LDX #6 ; max digits + 1 - LDY #3 ; bits per digit - 1 - JSR NMPRNT ; print result without leading zeros - JSR FRESH ; next line and clear - LDA #'&' ; print & sigil for octal - JSR CHROUT - LDA #0 ; clear digit counter - LDX #8 ; max digits + 1 - LDY #2 ; bits per digit - 1 - JSR PRINUM ; output number - JSR FRESH ; next line and clear - LDA #'%' ; print % sigil for binary - JSR CHROUT - LDA #0 ; clear digit counter - LDX #$18 ; max digits + 1 - LDY #0 ; bits per digit - 1 - JSR PRINUM ; output number - - JSR FRESH ; next line and clear - - LDA #'#' ; print % sigil for binary - JSR CHROUT - lda TMP0 ; 1st charaster - and #$1F - ora #$40 - jsr CHROUT - - lda TMP1 ; 2nd character - and #$03 - sta T1 - - lda TMP0 - asl - rol T1 - asl - rol T1 - asl - rol T1 - lda T1 - - ldx TMP1 ; - cpx #$c6 - beq @cvt3 ; it is a number - - ora #$40 - jsr CHROUT - - lda TMP1 ; 3rd character - bmi @cvt5 -@cvt4: ; it is a letter - lsr - lsr - and #$1f - ora #$40 - bne @cvt9 ; allways -@cvt5: ; it is a digit - lsr - lsr -@cvt3: - and #$0f - ora #$30 -@cvt9: - jsr CHROUT - JMP STRT ; back to mainloop - -; ----------------------------------------------------------------------------- -; convert binary to BCD - -CVTDEC: JSR COPY12 ; copy value from TMP0 to TMP2 - LDA #0 - LDX #2 ; clear 3 bytes in work buffer -DECML1: STA U0AA0,X - DEX - BPL DECML1 - LDY #16 ; 16 bits in input - PHP ; save status register - SEI ; make sure no interrupts occur with BCD enabled - SED -DECML2: ASL TMP2 ; rotate bytes out of input low byte - ROL TMP2+1 ; .. into high byte and carry bit - LDX #2 ; process 3 bytes -DECDBL: LDA U0AA0,X ; load current value of byte - ADC U0AA0,X ; add it to itself plus the carry bit - STA U0AA0,X ; store it back in the same location - DEX ; decrement byte counter - BPL DECDBL ; loop until all bytes processed - DEY ; decrement bit counter - BNE DECML2 ; loop until all bits processed - PLP ; restore processor status - RTS - -; load the input value and fall through to print it -PRINUM: PHA ; save accumulator - LDA TMP0 ; copy input low byte to work buffer - STA U0AA0+2 - LDA TMP0+1 ; copy input high byte to work buffer - STA U0AA0+1 - LDA #0 ; clear overflow byte in work buffer - STA U0AA0 - PLA ; restore accumulator - -; print number in specified base without leading zeros -NMPRNT: STA DIGCNT ; number of digits in accumulator - STY NUMBIT ; bits per digit passed in Y register -DIGOUT: LDY NUMBIT ; get bits to process - LDA #0 ; clear accumulator -ROLBIT: ASL U0AA0+2 ; shift bits out of low byte - ROL U0AA0+1 ; ... into high byte - ROL U0AA0 ; ... into overflow byte - ROL A ; ... into accumulator - DEY ; decrement bit counter - BPL ROLBIT ; loop until all bits processed - TAY ; check whether accumulator is 0 - BNE NZERO ; if not, print it - CPX #1 ; have we output the max number of digits? - BEQ NZERO ; if not, print it - LDY DIGCNT ; how many digits have we output? - BEQ ZERSUP ; skip output if digit is 0 -NZERO: INC DIGCNT ; increment digit counter - ORA #$30 ; add numeric value to ascii '0' to get ascii char - JSR CHROUT ; output character -ZERSUP: DEX ; decrement number of leading zeros - BNE DIGOUT ; next digit - RTS -; ----------------------------------------------------------------------------- -; disk status/command [@] -DSTAT: - JSR GETPAR - BNE CHGDEV ; if device address was given, use it - LDX FA ; otherwise, default to 8 - .BYTE $2C ; absolute BIT opcode consumes next word (LDX TMP0) -CHGDEV: LDX TMP0 ; load device address from parameter - CPX #4 ; make sure device address is in range 4-31 - BCC IOERR - CPX #32 - BCS IOERR - STX FA - STX TMP0 - LDA #0 ; clear status - STA STATUS - STA FNLEN ; empty filename - JSR GETCHR ; get next character - BEQ INSTAT1 ; null, display status - DEC CHRPNT ; back up 1 char - CMP #'$' ; $, display directory - BEQ DIRECT - LDA TMP0 ; command specified device to listen - JSR LISTEN - LDA #$6F ; secondary address 15 (only low nybble used) - JSR SECOND - -; send command to device -DCOMD: LDX CHRPNT ; get next character from buffer - INC CHRPNT - LDA BUF,X - BEQ INSTAT ; break out of loop if it's null - JSR CIOUT ; otherwise output it to the serial bus - BCC DCOMD ; unconditional loop:CIOUT clears carry before RTS - -; get device status -INSTAT: JSR UNLSN ; command device to unlisten -INSTAT1:JSR CRLF ; new line - LDA TMP0 ; load device address - JSR TALK ; command device to talk - LDA #$6F ; secondary address 15 (only low nybble used) - JSR TKSA -RDSTAT: JSR ACPTR ; read byte from serial bus - JSR CHROUT ; print it - CMP #$0D ; if the byte is CR, exit loop - BEQ DEXIT - LDA STATUS ; check status - AND #$BF ; ignore EOI bit - BEQ RDSTAT ; if no errors, read next byte -DEXIT: JSR UNTLK ; command device to stop talking - JMP STRT ; back to mainloop -IOERR: JMP ERROR ; handle error - -; get directory -DIRECT: LDA TMP0 ; load device address - JSR LISTEN ; command device to listen - LDA #$F0 ; secondary address 0 (only low nybble used) - JSR SECOND - LDX CHRPNT ; get index of next character -DIR2: LDA BUF,X ; get next character from buffer - BEQ DIR3 ; break if it's null - JSR CIOUT ; send character to device - INX ; increment characer index - BNE DIR2 ; loop if it hasn't wrapped to zero -DIR3: JSR UNLSN ; command device to unlisten - JSR CRLF ; new line - LDA TMP0 ; load device address - PHA ; save on stack - JSR TALK ; command device to talk - LDA #$60 ; secondary address 0 (only low nybble used) - JSR TKSA - LDY #3 ; read 3 16-bit values from device -DIRLIN: STY STORE ; ignore the first 2; 3rd is file size -DLINK: JSR ACPTR ; read low byte from device - STA TMP0 ; store it - LDA STATUS ; check status - BNE DREXIT ; exit if error or eof occurred - JSR ACPTR ; read high byte from device - STA TMP0+1 ; store it - LDA STATUS ; check status - BNE DREXIT ; exit if error or eof cocurred - DEC STORE ; decrement byte count - BNE DLINK ; loop if bytes remain - JSR CVTDEC ; convert last 16-bit value to decimal - LDA #0 ; clear digit count - LDX #6 ; max 6 digits - LDY #3 ; 3 bits per digit - JSR NMPRNT ; output number - LDA #' ' ; output space - JSR CHROUT -DNAME: JSR ACPTR ; get a filename character from the device - BEQ DMORE ; if it's null, break out of loop - LDX STATUS ; check for errors or eof - BNE DREXIT ; if found exit early - JSR CHROUT ; output character - CLC - BCC DNAME ; unconditional branch to read next char -DMORE: JSR CRLF - JSR STOP ; check for stop key - BEQ DREXIT ; exit early if pressed - JSR GETIN ; pause if a key was pressed - BEQ NOPAWS -PAWS: JSR GETIN ; wait until another key is pressed - BEQ PAWS -NOPAWS: LDY #2 - BNE DIRLIN ; unconditional branch to read next file -DREXIT: JSR UNTLK ; command device to untalk - PLA ; restore accumulator - JSR LISTEN ; command device to listen - LDA #$E0 ; secondary address 0 (only low nybble is used) - JSR SECOND - JSR UNLSN ; command device to unlisten - JMP STRT ; back to mainloop ; ----------------------------------------------------------------------------- .include "utils.s" @@ -998,66 +455,6 @@ msgc2: .asciiz "ibrk " msgc3: .asciiz "inmi " -listvars: - ldxy VARTAB - stxy T1 - -lvl2: lda T2 ; at end? - cmp ARYTAB+1 - bne lvl3 - lda T1 - cmp ARYTAB -lvl3: bmi lvlgo - rts - -lvlgo: - ldy #0 - lda (T1),y - bmi lvnext1 ; it's a number - iny - lda (T1),y - bpl lvnext1 ; not a string - - ldxy T1 - jsr hexoutxy - chrout ':' - - ldy #0 - lda (T1),y - and #$7f - jsr CHROUT - iny - lda (T1),y - and #$7f - bne @lvl4 - lda #' ' -@lvl4: jsr CHROUT - chrout ' ' - iny - lda (T1),y - sta COUNT - jsr WRTWO - chrout ' ' - iny - lda (T1),y - tax - iny - lda (T1),y - tay - jsr hexoutxy - chrout ' ' - lda COUNT - jsr strout - jsr CRLF -lvnext1: - ; next - lda T1 - add #7 - sta T1 - bcc lvl2 - inc T2 - bne lvl2 -; msgout: stx T1 sty T2 ldy #0 diff --git a/tools/pip.128.o b/tools/pip.128.o index dbf7767..bd18cea 100644 Binary files a/tools/pip.128.o and b/tools/pip.128.o differ