2019-06-11 05:13:46 +10:00
|
|
|
sdctMain:
|
|
|
|
ld hl, .sWriting
|
|
|
|
call printstr
|
|
|
|
ld hl, 0
|
|
|
|
ld de, SDCT_RAMSTART
|
|
|
|
.wLoop:
|
|
|
|
ld a, (de)
|
2019-06-16 03:41:20 +10:00
|
|
|
; To avoid overwriting important data and to test the 24-bit addressing,
|
|
|
|
; we set DE to 12 instead of zero
|
|
|
|
push de ; <|
|
|
|
|
ld de, 12 ; |
|
2019-10-31 07:59:35 +11:00
|
|
|
call sdcPutB ; |
|
2019-06-16 03:41:20 +10:00
|
|
|
pop de ; <|
|
2019-06-11 05:13:46 +10:00
|
|
|
jr nz, .error
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
; Stop looping if DE == 0
|
|
|
|
xor a
|
|
|
|
cp e
|
|
|
|
jr nz, .wLoop
|
|
|
|
; print some kind of progress
|
|
|
|
call printHexPair
|
|
|
|
cp d
|
|
|
|
jr nz, .wLoop
|
|
|
|
; Finished writing
|
|
|
|
ld hl, .sReading
|
|
|
|
call printstr
|
|
|
|
ld hl, 0
|
|
|
|
ld de, SDCT_RAMSTART
|
|
|
|
.rLoop:
|
2019-06-16 03:41:20 +10:00
|
|
|
push de ; <|
|
|
|
|
ld de, 12 ; |
|
2019-10-31 07:59:35 +11:00
|
|
|
call sdcGetB ; |
|
2019-06-16 03:41:20 +10:00
|
|
|
pop de ; <|
|
2019-06-11 05:13:46 +10:00
|
|
|
jr nz, .error
|
|
|
|
ex de, hl
|
|
|
|
cp (hl)
|
|
|
|
ex de, hl
|
|
|
|
jr nz, .notMatching
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
; Stop looping if DE == 0
|
|
|
|
xor a
|
|
|
|
cp d
|
|
|
|
jr nz, .rLoop
|
|
|
|
cp e
|
|
|
|
jr nz, .rLoop
|
|
|
|
; Finished checking
|
|
|
|
xor a
|
|
|
|
ld hl, .sOk
|
|
|
|
jp printstr ; returns
|
|
|
|
.notMatching:
|
|
|
|
; error position is in HL, let's preserve it
|
|
|
|
ex de, hl
|
|
|
|
ld hl, .sNotMatching
|
|
|
|
call printstr
|
|
|
|
ex de, hl
|
|
|
|
jp printHexPair ; returns
|
|
|
|
.error:
|
|
|
|
ld hl, .sErr
|
|
|
|
jp printstr ; returns
|
|
|
|
|
|
|
|
.sWriting:
|
|
|
|
.db "Writing", 0xd, 0xa, 0
|
|
|
|
.sReading:
|
|
|
|
.db "Reading", 0xd, 0xa, 0
|
|
|
|
.sNotMatching:
|
|
|
|
.db "Not matching at pos ", 0xd, 0xa, 0
|
|
|
|
.sErr:
|
|
|
|
.db "Error", 0xd, 0xa, 0
|
|
|
|
.sOk:
|
|
|
|
.db "OK", 0xd, 0xa, 0
|