range ram $4000 $4FFF section ram ld sp $6000 program_eeprom ld de $8000 .loop # Load a 64 byte block from the PC to SRAM. ld hl $0000 ld de $5000 ld bc 64 ldir # If desired, Activate the AT28C256's software write protection via # magic bytes. If this is done, the chip can still be reprogrammed, # but not without continuing to use this sequence when programming. #ld a $AA; ld [$D555] a #ld a $55; ld [$AAAA] a #ld a $A0; ld [$D555] a # Copy the 64 byte block from SRAM to the EEPROM. ld hl $5000 ld bc 63 ldir # The last byte is copied manually, to keep the value in A ld a [hl] ld [de] a # Then keep reading that last byte until it matches A, as this # is how the EEPROM indicates when programming is complete. .wait ld a [de] cp [hl] jr nz .wait # Increment the EEPROM address, for that last byte. inc de # If we haven't cycled back to address $0000, then repeat, so # as to program the rest of the EEPROM, 64 bytes a at a time. xor a or d jr nz .loop # Return program control back to the PC jp $0000 output 'burn.ram' .ram. $-1