10
20
30
40 :
50 fname$="NVRAM"
60 DIM mcode% &200
70 BYTEV=&20A
80 load%=&FFFF0AB4
90 NVMREG =&FC38:
100 NVMDATA=&FC3C:
110 NVMSIZE=128 :
120 NVMRAM =14 :
130 :
140 FOR P=0 TO 1
150 P%=load%:O%=mcode%
160 [OPT P*3+4
170 .go%
180 PHP:SEI
190 LDA BYTEV+0:LDX oldbyte+1
200 STX BYTEV+0:STA oldbyte+1
210 LDA BYTEV+1:LDX oldbyte+2
220 STX BYTEV+1:STA oldbyte+2
230 PLP:RTS
240 :
250 .newbyte
260 CMP #161:BEQ nvm :\ A=161, read
270 CMP #162:BEQ nvm :\ A=162, write
280 .oldbyte
290 JMP newbyte
300 .nvm
310 CPX #255:BEQ nvmsz
320 PHA:TXA:ADC #NVMRAM:CPX #NVMSIZE-NVMRAM
330 CLV:TAX:PLA:BCS nvmov
340 STX NVMREG:CMP #162:BCC nvmrd
350 .nvmwr:STY NVMDATA:CLC:RTS
360 .nvmrd:LDY NVMDATA:RTS
370 .nvmsz:LDY #NVMSIZE-NVMRAM-1:CLC
380 .nvmov:RTS
390 ]NEXT
400 PRINT"*SAVE ";fname$;" ";~mcode%;" ";~O%;" ";~go%OR&FFFF0000;" ";~load%