10
20 :
30 OSWRCH=&FFEE:OSASCI=&FFE3
40 OSNEWL=&FFE7:OSARGS=&FFDA
50 :
60 mcode%=TOP+&3000:HIMEM=mcode%
70 Addr=&A8:Temp=&AA
80 LineY=&AA:CommY=&AB
90 Load=&AA:Exec=&AC:Length=&AE
100 :
110 FOR P=0 TO 1
120 P%=&8000:O%=mcode%
130 [OPT P*3+4
140 JMP Lang:JMP Serv
150 EQUB &82:EQUB copyright-&8000
160 EQUB 0:EQUS "COMMAND ROM"
170 EQUB 0:EQUS "0.01 (28 Dec 1992)"
180 .copyright
190 EQUB 0:EQUS "(C)J.G.Harston"
200 EQUB 0
210 EQUS STRING$(&8040-P%,CHR$0)
220 JMP InitAddr
230 JMP NextAddr
240 JMP SkipToCR
250 JMP pr_name
260 .Lang
270 RTS
280 :
290 .Serv
300 TAX:LDA &A8:PHA:STX &A8
310 LDX #1:.ServLp
320 LDA &A8,X:PHA:INX:CPX #8
330 BNE ServLp
340 LDX &A8:JSR TryServ
350 STX &A8:LDX #7:.ServLp2
360 PLA:STA &A8,X:DEX:BNE ServLp2
370 LDX &A8:PLA:STA &A8
380 TXA:LDX &F4:RTS
390 :
400 .TryServ
410 CPX #4:BEQ Serv4
420 CPX #6:BEQ Serv6
430 CPX #9:BEQ Serv9
440 RTS
450 :
460 .Serv9:JMP serv9
470 :
480 .Serv6
490 JSR RestoreArgs:LDX #6:RTS
500 :
510 .Serv4
520 TYA:PHA:STA LineY
530 JSR InitAddr:STY CommY
540 .Serv4Lp2
550 LDY LineY:LDA (&F2),Y:CMP #ASC"."
560 BEQ Serv4Dot
570 AND #&DF:LDY CommY:CMP (Addr),Y
580 BNE Serv4NotFound
590 INC LineY:INY:STY CommY
600 LDA (Addr),Y:CMP #ASC"!"
610 BCS Serv4Lp2:BCC Serv4Found
620 .Serv4NotFound
630 JSR SkipToCR:JSR NextAddr
640 PLA:PHA:STA LineY
650 LDA (Addr),Y:BNE Serv4Lp2
660 PLA:TAY:LDX #4:RTS:\ No match
670 .Serv4Dot
680 INC LineY:LDY CommY
690 .Serv4Found
700 PLA:JSR SkipToCR:LDA LineY:PHA
710 LDX #0:.Serv4Lp3
720 LDA (Addr),Y:STA Load,X
730 INY:INX:CPX #6:BNE Serv4Lp3
740 TYA:CLC:ADC Addr:STA Addr
750 LDA Addr+1:ADC #0:STA Addr+1
760 \ Addr= source
770 \ Load= dest
780 \ Exec= exec
790 \ Length=len
800 LDY #0:LDA Length+1:BEQ Serv4Lp6
810 .Serv4Lp5
820 LDA (Addr),Y:STA (Load),Y
830 INY:BNE Serv4Lp5
840 INC Addr+1:INC Load+1
850 DEC Length+1:BNE Serv4Lp5
860 .Serv4Lp6
870 LDA (Addr),Y:STA (Load),Y
880 INY:CPY Length:BNE Serv4Lp6
890 PLA:TAY:.SkipSpaces
900 LDA (&F2),Y:INY:CMP #ASC" "
910 BEQ SkipSpaces:DEY
920 TYA:CLC:ADC &F2:STA Addr
930 LDA #0:ADC &F3:STA Addr+1
940 \ Addr=> parameters
950 LDA &DBD:PHA:LDA &DBE:PHA
960 LDA &DBF:PHA:\ Save old ARGSXV
970 LDA #new_args AND 255:STA &DBD
980 LDA #new_args DIV 256:STA &DBE
990 LDA &F4:STA &DBF
1000 TSX:TXA:LDX &F4:STA &DF0,X
1010 JSR CallExec:JSR RestoreArgs
1020 PLA:PLA:PLA:\ Clear stack
1030 LDX #0:RTS
1040 :
1050 .new_args
1060 JSR RestoreArgs
1070 CMP #1:BNE DoOldArgs
1080 CPY #0:BNE DoOldArgs
1090 \ Read command pointer
1100 LDA Addr:PHA:LDA Addr+1
1110 STA 1,X:PLA:STA 0,X
1120 LDA #&FF:STA 2,X:STA 3,X
1130 RTS
1140 .DoOldArgs
1150 JMP OSARGS
1160 :
1170 .RestoreArgs
1180 LDA &DBF:CMP &F4:BNE ArgsDone
1190 LDX &F4:LDA &DF0,X:TAX
1200 LDA &101,X:STA &DBF
1210 LDA &102,X:STA &DBE
1220 LDA &103,X:STA &DBD
1230 .ArgsDone
1240 RTS
1250 :
1260 .CallExec
1270 JMP (Exec)
1280 :
1290 .SkipToCR
1300 LDA (Addr),Y:INY:CMP #13
1310 BNE SkipToCR
1320 RTS
1330 :
1340 .pr_name
1350 JSR OSNEWL:LDX #0
1360 .pr_name_lp
1370 LDA &8009,X:BEQ pr_name_end
1380 JSR OSWRCH:INX:BNE pr_name_lp
1390 .pr_name_end
1400 JMP OSNEWL
1410 :
1420 .serv9
1430 TYA:PHA:JSR pr_name
1440 LDX #0:.HelpLp0
1450 LDA &8009,X:CMP #ASC" ":BEQ HelpOk
1460 LDA (&F2),Y:CMP #ASC"."
1470 BEQ HelpOk
1480 AND #&DF:CMP &8009,X:BNE HelpExit
1490 INX:INY:BNE HelpLp0
1500 .HelpOk
1510 JSR InitAddr
1520 .HelpLp3
1530 LDA #32:JSR OSWRCH:JSR OSWRCH
1540 .HelpLp4
1550 LDA (Addr),Y:JSR OSASCI
1560 INY:CMP #13:BNE HelpLp4
1570 JSR NextAddr
1580 LDA (Addr),Y:BNE HelpLp3
1590 PLA:TAY:LDA (&F2),Y:CMP #ASC"."
1600 BEQ HelpExit2
1610 LDX #0:RTS
1620 .HelpExit
1630 PLA:TAY
1640 .HelpExit2
1650 LDX #9:RTS
1660 :
1670 .InitAddr
1680 LDA #DataStart AND &FF:STA Addr
1690 LDA #DataStart DIV 256:STA Addr+1
1700 LDY #0:RTS
1710 :
1720 .NextAddr
1730 INY:INY:INY:INY
1740 LDA (Addr),Y:STA Temp:INY
1750 LDA (Addr),Y:STA Temp+1
1760 LDA Addr:CLC:ADC Temp:STA Addr
1770 LDA Addr+1:ADC Temp+1:STA Addr+1
1780 INY:TYA:CLC:ADC Addr:STA Addr
1790 LDA Addr+1:ADC #0:STA Addr+1
1800 LDY #0:RTS
1810 :
1820 .DataStart
1830 EQUS "TEST":EQUB 13
1840 EQUW &900:EQUW &900:EQUW &14
1850 LDX #&A8:LDY #0:LDA #1:JSR &FFDA
1860 .LP
1870 LDA (&A8),Y:JSR &FFE3:INY
1880 CMP #13:BNE LP:RTS
1890 :
1900 BRK:\ End marker
1910 EQUB 13:EQUW 0:EQUW 0:EQUW 0:BRK
1920 ]NEXT
1930 PRINT"*SAVE CommROM ";~mcode%;" ";~O%;" FFFF0000 FFFBBC00"