10
20
30
40 :
50 :
60 OSASCI=&FFE3:OSWORD=&FFF1
70 DIM mcode% &1000
80 FOR P=0 TO 1
90 P%=&8000:O%=mcode%
100 [OPT P*3+4
110 \ Boilerplate
120 \ -----------
130 BRK:BRK:BRK:JMP Service
140 EQUB &82:EQUB Copyright-&8000
150 EQUB &00:EQUS "TESTROM"
160 .Copyright
170 EQUB &00:EQUS "(C)"
180 EQUB &00
190 \ -----------
200 :
210 :
220 \ Demo command, print the time
230 \ ----------------------------
240 .Demo
250 TSX:TXA:TYA:SEC:SBC #32:TAX:TXS :\ Reserve 32 bytes on stack
260 TYA:PHA :\ Save old stack pointer
270 LDY #1:INX :\ XY=>space on the stack, &100,X=>space on the stack
280 LDA #0:STA &100,X :\ (XY+0)=0 - read RTC string
290 LDA #14:JSR OSWORD :\ Read the RTC. We must assume A/X/Y corrupted.
300 TSX:INX:INX :\ X points to the space on the stack again
310 LDA &100,X:BEQ NoTime :\ No RTC exists
320 .DemoLp
330 LDA &100,X:JSR OSASCI :\ Print the returned string
340 INX:CMP #13:BNE DemoLp
350 .NoTime
360 PLA:TAX:TXS :\ Restore stack pointer
370 RTS
380 :
390 :
400 :
410 :
420 \ Boilerplate
430 \ -----------
440 .Service
450 PHA:LDA &DF0,X:BMI P%+4:EOR #&40
460 ASL A:BPL ServDisabled:PLA
470 CMP #&04:BEQ Serv04:RTS
480 .ServDisabled
490 PLA:RTS
500 .Serv04
510 TYA:PHA:DEY:LDX #&FF
520 .Serv4Lp
530 INX:INY:LDA (&F2),Y
540 CMP #ASC".":BEQ Serv4Dot
550 CMP #ASC"!":BCC Serv4End
560 CMP &8009,X:BEQ Serv4Lp
570 EOR #&20
580 CMP &8009,X:BEQ Serv4Lp
590 .Serv4Quit
600 PLA:TAY:LDA #4:RTS
610 .Serv4End
620 DEY:LDA &8009,X:BNE Serv4Quit
630 .Serv4Dot
640 PLA:JSR Demo:LDA #0:RTS
650 ]NEXT
660 PRINT"*SAVE STACKROM ";~mcode%;" ";~O%