My SBC2 uses essentially the same code. This has been simplified for the sake of clarity as my code first copies itself from the System Monitor in EEPROM to RAM before executing. This routine will copy 16k from RAM located from $1000-$4FFF to EEPROM located at $8000-$BFFF.
This routine has to be located in RAM also, at say address $0800 for example.
Here's the code:
Code:
AddPtr = $e0 ; zp pointer
DestPtr = $e2 ; zp pointer
LDA #$00
STA AddPtr
LDA #$10
STA AddPtr+1 ; start of RAM source
LDA #$00
STA DestPtr
LDA #$80 ; start of EEPROM
STA DestPtr+1
Loop LDA (AddrPtr) ; Moves one byte
STA (DestPtr) ;
EEPROM_TEST LDA (AddrPtr) ; Read Source
EOR (DestPtr) ; EOR with EEPROM Data
bmi EEPROM_TEST ; Bit 7=0 if write is done
INC AddPtr ; pointers are in sync
INC DestPtr ; so we can inc together
BNE Loop
INC AddPtr+1
INC DestPtr+1 ; inc upper byte
LDA #$C0 ; 16k copied when
CMP DestPtr ; DespPtr+1 = $C0
BNE Loop
RTS
The polling mode of my EEPROM states that bit 7 will be read as opposite of the data written while the write sequence is in progress and will return a matching value when the write is complete. I simply use the EOR instruction to test the source and destination bits. It works quite well.
Daryl
_________________
Please visit my website ->
https://sbc.rictor.org/