Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1008B

  1. ; If you find youself needing to write to an EEPROM through a shell that isn't
  2. ; built for this, compile this dependency-less code (change memory offsets as
  3. ; needed) and run it in a USR-like fashion.
  4. ld bc, 0x1000 ; bytecount to write
  5. ld de, 0xd000 ; source data
  6. ld hl, 0x2000 ; dest EEPROM memory mapping
  7. loop:
  8. ld a, (de)
  9. ld (hl), a
  10. push de ; --> lvl 1
  11. push bc ; --> lvl 2
  12. ld bc, 0x2000 ; Should be plenty enough to go > 10ms
  13. ld e, a ; save expected data for verification
  14. wait:
  15. ; as long as writing operation is running, IO/6 will toggle at each
  16. ; read attempt and IO/7 will be the opposite of what was written. Simply
  17. ; wait until the read operation yields the same value as what we've
  18. ; written
  19. ld a, (hl)
  20. cp e
  21. jr z, waitend
  22. dec bc
  23. ld a, b
  24. or c
  25. jr nz, wait
  26. ; mismatch
  27. pop bc ; <-- lvl 2
  28. pop de ; <-- lvl 1
  29. ld a, 1 ; nonzero
  30. or a ; unset Z
  31. ret
  32. waitend:
  33. pop bc ; <-- lvl 2
  34. pop de ; <-- lvl 1
  35. inc hl
  36. inc de
  37. dec bc
  38. ld a, b
  39. or c
  40. jr nz, loop
  41. ret ; Z already set