mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 16:48:05 +11:00
recipes/rc2014/eeprom: add usr.asm
A little life saver if your target shell doesn't have a proper at28w.
This commit is contained in:
parent
beaea6f978
commit
fb93fcd6e6
43
recipes/rc2014/eeprom/usr.asm
Normal file
43
recipes/rc2014/eeprom/usr.asm
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
; If you find youself needing to write to an EEPROM through a shell that isn't
|
||||||
|
; built for this, compile this dependency-less code (change memory offsets as
|
||||||
|
; needed) and run it in a USR-like fashion.
|
||||||
|
|
||||||
|
ld bc, 0x1000 ; bytecount to write
|
||||||
|
ld de, 0xd000 ; source data
|
||||||
|
ld hl, 0x2000 ; dest EEPROM memory mapping
|
||||||
|
|
||||||
|
loop:
|
||||||
|
ld a, (de)
|
||||||
|
ld (hl), a
|
||||||
|
push de ; --> lvl 1
|
||||||
|
push bc ; --> lvl 2
|
||||||
|
ld bc, 0x2000 ; Should be plenty enough to go > 10ms
|
||||||
|
ld e, a ; save expected data for verification
|
||||||
|
wait:
|
||||||
|
; as long as writing operation is running, IO/6 will toggle at each
|
||||||
|
; read attempt and IO/7 will be the opposite of what was written. Simply
|
||||||
|
; wait until the read operation yields the same value as what we've
|
||||||
|
; written
|
||||||
|
ld a, (hl)
|
||||||
|
cp e
|
||||||
|
jr z, waitend
|
||||||
|
dec bc
|
||||||
|
ld a, b
|
||||||
|
or c
|
||||||
|
jr nz, wait
|
||||||
|
; mismatch
|
||||||
|
pop bc ; <-- lvl 2
|
||||||
|
pop de ; <-- lvl 1
|
||||||
|
ld a, 1 ; nonzero
|
||||||
|
or a ; unset Z
|
||||||
|
ret
|
||||||
|
waitend:
|
||||||
|
pop bc ; <-- lvl 2
|
||||||
|
pop de ; <-- lvl 1
|
||||||
|
inc hl
|
||||||
|
inc de
|
||||||
|
dec bc
|
||||||
|
ld a, b
|
||||||
|
or c
|
||||||
|
jr nz, loop
|
||||||
|
ret ; Z already set
|
Loading…
Reference in New Issue
Block a user