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.

73 line
1.2KB

  1. sdctMain:
  2. ld hl, .sWriting
  3. call printstr
  4. ld hl, 0
  5. ld de, SDCT_RAMSTART
  6. .wLoop:
  7. ld a, (de)
  8. ; To avoid overwriting important data and to test the 24-bit addressing,
  9. ; we set DE to 12 instead of zero
  10. push de ; <|
  11. ld de, 12 ; |
  12. call sdcPutB ; |
  13. pop de ; <|
  14. jr nz, .error
  15. inc hl
  16. inc de
  17. ; Stop looping if DE == 0
  18. xor a
  19. cp e
  20. jr nz, .wLoop
  21. ; print some kind of progress
  22. call printHexPair
  23. cp d
  24. jr nz, .wLoop
  25. ; Finished writing
  26. ld hl, .sReading
  27. call printstr
  28. ld hl, 0
  29. ld de, SDCT_RAMSTART
  30. .rLoop:
  31. push de ; <|
  32. ld de, 12 ; |
  33. call sdcGetB ; |
  34. pop de ; <|
  35. jr nz, .error
  36. ex de, hl
  37. cp (hl)
  38. ex de, hl
  39. jr nz, .notMatching
  40. inc hl
  41. inc de
  42. ; Stop looping if DE == 0
  43. xor a
  44. cp d
  45. jr nz, .rLoop
  46. cp e
  47. jr nz, .rLoop
  48. ; Finished checking
  49. xor a
  50. ld hl, .sOk
  51. jp printstr ; returns
  52. .notMatching:
  53. ; error position is in HL, let's preserve it
  54. ex de, hl
  55. ld hl, .sNotMatching
  56. call printstr
  57. ex de, hl
  58. jp printHexPair ; returns
  59. .error:
  60. ld hl, .sErr
  61. jp printstr ; returns
  62. .sWriting:
  63. .db "Writing", 0xd, 0xa, 0
  64. .sReading:
  65. .db "Reading", 0xd, 0xa, 0
  66. .sNotMatching:
  67. .db "Not matching at pos ", 0xd, 0xa, 0
  68. .sErr:
  69. .db "Error", 0xd, 0xa, 0
  70. .sOk:
  71. .db "OK", 0xd, 0xa, 0