Skip to content

Commit a036a8b

Browse files
committed
kmon.s split into smaller parts
1 parent 45b90c2 commit a036a8b

File tree

8 files changed

+236
-4
lines changed

8 files changed

+236
-4
lines changed

boot/autostart64.128.o

0 Bytes
Binary file not shown.

boot/autostart64.o

0 Bytes
Binary file not shown.

boot/bootsect.128.o

0 Bytes
Binary file not shown.

run64.d81

0 Bytes
Binary file not shown.

s/issue,s

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
Q: How much does it cost to ride the Unibus?
2-
A: 2 bits.
1+
You will get what you deserve.
32

43

5-
Training is everything. The peach was once a bitter almond; cauliflower is
6-
nothing but cabbage with a college education.
4+
The true Southern watermelon is a boon apart, and not to be mentioned with
5+
commoner things. It is chief of the world's luxuries, king by the grace of God
6+
over all the fruits of the earth. When one has tasted it, he knows what the
7+
angels eat. It was not a Southern watermelon that Eve took; we know it because
8+
she repented.
79
-- Mark Twain, "Pudd'nhead Wilson's Calendar"

tools/dos.s

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
; -----------------------------------------------------------------------------
2+
; load, save, or verify [LSV]
3+
LD: LDY #1 ; default to reading from tape, device #1
4+
STY FA
5+
STY SA ; default to secondary address #1
6+
DEY
7+
STY FNLEN ; start with an empty filename
8+
STY STATUS ; clear status
9+
LDA #>STAGE ; set filename pointer to staging buffer
10+
STA FNADR+1
11+
LDA #<STAGE
12+
STA FNADR
13+
L1: JSR GETCHR ; get a character
14+
BEQ LSHORT ; no filename given, try load or verify from tape
15+
CMP #$20 ; skip leading spaces
16+
BEQ L1
17+
CMP #$22 ; error if filename doesn't start with a quote
18+
BNE LERROR
19+
LDX CHRPNT ; load current char pointer into index reg
20+
L3: LDA BUF,X ; load current char from buffer to accumulator
21+
BEQ LSHORT ; no filename given, try load or verify from tape
22+
INX ; next char
23+
CMP #$22 ; is it a quote?
24+
BEQ L8 ; if so, we've reached the end of the filename
25+
STA (FNADR),Y ; if not, save character in filename buffer
26+
INC FNLEN ; increment filename length
27+
INY
28+
CPY #ESTAGE-STAGE ; check whether buffer is full
29+
BCC L3 ; if not, get another character
30+
LERROR: JMP ERROR ; if so, handle error
31+
L8: STX CHRPNT ; set character pointer to the current index
32+
JSR GETCHR ; eat separator between filename and device #
33+
BEQ LSHORT ; no separator, try to load or verify from tape
34+
JSR GETPAR ; get device number
35+
BCS LSHORT ; no device # given, try load or verify from tape
36+
LDA TMP0 ; set device number for kernal routines
37+
STA FA
38+
JSR GETPAR ; get start address for load or save in TMP0
39+
BCS LSHORT ; no start address, try to load or verify
40+
JSR COPY12 ; transfer start address to TMP2
41+
JSR GETPAR ; get end address for save in TMP0
42+
BCS LDADDR ; no end address, try to load to given start addr
43+
JSR CRLF ; new line
44+
LDX TMP0 ; put low byte of end address in X
45+
LDY TMP0+1 ; put high byte of end address in Y
46+
LDA SAVY ; confirm that we're doing a save
47+
CMP #'s'
48+
BNE LERROR ; if not, error due to too many params
49+
LDA #0
50+
STA SA ; set secondary address to 0
51+
LDA #TMP2 ; put addr of zero-page pointer to data in A
52+
JSR SAVE ; call kernal save routine
53+
LSVXIT: JMP STRT ; back to mainloop
54+
LSHORT: LDA SAVY ; check which command we received
55+
CMP #'v'
56+
BEQ LOADIT ; we're doing a verify so don't set A to 0
57+
CMP #'l'
58+
BNE LERROR ; error due to not enough params for save
59+
LDA #0 ; 0 in A signals load, anything else is verify
60+
LOADIT: JSR LOAD ; call kernal load routine
61+
LDA STATUS ; get i/o status
62+
AND #$10 ; check bit 5 for checksum error
63+
BEQ LSVXIT ; if no error go back to mainloop
64+
LDA SAVY ; ?? not sure what these two lines are for...
65+
BEQ LERROR ; ?? SAVY will never be 0, so why check?
66+
LDY #MSG6-MSGBAS ; display "ERROR" if checksum didn't match
67+
JSR SNDMSG
68+
JMP STRT ; back to mainloop
69+
LDADDR: LDX TMP2 ; load address low byte in X
70+
LDY TMP2+1 ; load address high byte in Y
71+
LDA #0 ; 0 in A signals load
72+
STA SA ; secondary addr 0 means load to addr in X and Y
73+
BEQ LSHORT ; execute load
74+
75+
; -----------------------------------------------------------------------------
76+
; disk status/command [@]
77+
DSTAT:
78+
JSR GETPAR
79+
BNE CHGDEV ; if device address was given, use it
80+
LDX FA ; otherwise, default to 8
81+
.BYTE $2C ; absolute BIT opcode consumes next word (LDX TMP0)
82+
CHGDEV: LDX TMP0 ; load device address from parameter
83+
CPX #4 ; make sure device address is in range 4-31
84+
BCC IOERR
85+
CPX #32
86+
BCS IOERR
87+
STX FA
88+
STX TMP0
89+
LDA #0 ; clear status
90+
STA STATUS
91+
STA FNLEN ; empty filename
92+
JSR GETCHR ; get next character
93+
BEQ INSTAT1 ; null, display status
94+
DEC CHRPNT ; back up 1 char
95+
CMP #'$' ; $, display directory
96+
BEQ DIRECT
97+
LDA TMP0 ; command specified device to listen
98+
JSR LISTEN
99+
LDA #$6F ; secondary address 15 (only low nybble used)
100+
JSR SECOND
101+
102+
; send command to device
103+
DCOMD: LDX CHRPNT ; get next character from buffer
104+
INC CHRPNT
105+
LDA BUF,X
106+
BEQ INSTAT ; break out of loop if it's null
107+
JSR CIOUT ; otherwise output it to the serial bus
108+
BCC DCOMD ; unconditional loop:CIOUT clears carry before RTS
109+
110+
; get device status
111+
INSTAT: JSR UNLSN ; command device to unlisten
112+
INSTAT1:JSR CRLF ; new line
113+
LDA TMP0 ; load device address
114+
JSR TALK ; command device to talk
115+
LDA #$6F ; secondary address 15 (only low nybble used)
116+
JSR TKSA
117+
RDSTAT: JSR ACPTR ; read byte from serial bus
118+
JSR CHROUT ; print it
119+
CMP #$0D ; if the byte is CR, exit loop
120+
BEQ DEXIT
121+
LDA STATUS ; check status
122+
AND #$BF ; ignore EOI bit
123+
BEQ RDSTAT ; if no errors, read next byte
124+
DEXIT: JSR UNTLK ; command device to stop talking
125+
JMP STRT ; back to mainloop
126+
IOERR: JMP ERROR ; handle error
127+
128+
; get directory
129+
DIRECT: LDA TMP0 ; load device address
130+
JSR LISTEN ; command device to listen
131+
LDA #$F0 ; secondary address 0 (only low nybble used)
132+
JSR SECOND
133+
LDX CHRPNT ; get index of next character
134+
DIR2: LDA BUF,X ; get next character from buffer
135+
BEQ DIR3 ; break if it's null
136+
JSR CIOUT ; send character to device
137+
INX ; increment characer index
138+
BNE DIR2 ; loop if it hasn't wrapped to zero
139+
DIR3: JSR UNLSN ; command device to unlisten
140+
JSR CRLF ; new line
141+
LDA TMP0 ; load device address
142+
PHA ; save on stack
143+
JSR TALK ; command device to talk
144+
LDA #$60 ; secondary address 0 (only low nybble used)
145+
JSR TKSA
146+
LDY #3 ; read 3 16-bit values from device
147+
DIRLIN: STY STORE ; ignore the first 2; 3rd is file size
148+
DLINK: JSR ACPTR ; read low byte from device
149+
STA TMP0 ; store it
150+
LDA STATUS ; check status
151+
BNE DREXIT ; exit if error or eof occurred
152+
JSR ACPTR ; read high byte from device
153+
STA TMP0+1 ; store it
154+
LDA STATUS ; check status
155+
BNE DREXIT ; exit if error or eof cocurred
156+
DEC STORE ; decrement byte count
157+
BNE DLINK ; loop if bytes remain
158+
JSR CVTDEC ; convert last 16-bit value to decimal
159+
LDA #0 ; clear digit count
160+
LDX #6 ; max 6 digits
161+
LDY #3 ; 3 bits per digit
162+
JSR NMPRNT ; output number
163+
LDA #' ' ; output space
164+
JSR CHROUT
165+
DNAME: JSR ACPTR ; get a filename character from the device
166+
BEQ DMORE ; if it's null, break out of loop
167+
LDX STATUS ; check for errors or eof
168+
BNE DREXIT ; if found exit early
169+
JSR CHROUT ; output character
170+
CLC
171+
BCC DNAME ; unconditional branch to read next char
172+
DMORE: JSR CRLF
173+
JSR STOP ; check for stop key
174+
BEQ DREXIT ; exit early if pressed
175+
JSR GETIN ; pause if a key was pressed
176+
BEQ NOPAWS
177+
PAWS: JSR GETIN ; wait until another key is pressed
178+
BEQ PAWS
179+
NOPAWS: LDY #2
180+
BNE DIRLIN ; unconditional branch to read next file
181+
DREXIT: JSR UNTLK ; command device to untalk
182+
PLA ; restore accumulator
183+
JSR LISTEN ; command device to listen
184+
LDA #$E0 ; secondary address 0 (only low nybble is used)
185+
JSR SECOND
186+
JSR UNLSN ; command device to unlisten
187+
JMP STRT ; back to mainloop

tools/pip.128.o

0 Bytes
Binary file not shown.

tools/ted.cfg

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FEATURES {
2+
STARTADDRESS: default = $1001;
3+
}
4+
SYMBOLS {
5+
__LOADADDR__: type = import;
6+
__EXEHDR__: type = import;
7+
__STACKSIZE__: type = weak, value = $0800; # 2k stack
8+
__HIMEM__: type = weak, value = $FD00;
9+
}
10+
MEMORY {
11+
ZP: file = "", define = yes, start = $0002, size = $001A;
12+
LOADADDR: file = %O, start = %S - 2, size = $0002;
13+
HEADER: file = %O, define = yes, start = %S, size = $000D;
14+
MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __MAIN_START__ - __STACKSIZE__;
15+
}
16+
SEGMENTS {
17+
ZEROPAGE: load = ZP, type = zp;
18+
LOADADDR: load = LOADADDR, type = ro;
19+
EXEHDR: load = HEADER, type = ro;
20+
STARTUP: load = MAIN, type = ro;
21+
LOWCODE: load = MAIN, type = ro, optional = yes;
22+
CODE: load = MAIN, type = ro;
23+
ONCE: load = MAIN, type = ro, optional = yes;
24+
RODATA: load = MAIN, type = ro;
25+
DATA: load = MAIN, type = rw;
26+
INIT: load = MAIN, type = bss;
27+
BSS: load = MAIN, type = bss, define = yes;
28+
}
29+
FEATURES {
30+
CONDES: type = constructor,
31+
label = __CONSTRUCTOR_TABLE__,
32+
count = __CONSTRUCTOR_COUNT__,
33+
segment = ONCE;
34+
CONDES: type = destructor,
35+
label = __DESTRUCTOR_TABLE__,
36+
count = __DESTRUCTOR_COUNT__,
37+
segment = RODATA;
38+
CONDES: type = interruptor,
39+
label = __INTERRUPTOR_TABLE__,
40+
count = __INTERRUPTOR_COUNT__,
41+
segment = RODATA,
42+
import = __CALLIRQ__;
43+
}

0 commit comments

Comments
 (0)