AppleIISd/AppleIISd.lst

768 lines
32 KiB
Plaintext
Raw Normal View History

1 ********************************
2 *
3 * Apple][Sd Firmware
4 * Version 0.6
5 *
6 * (c) Florian Reitz, 2017
7 *
8 * X register usually contains SLOT16
9 * Y register is used for counting or SLOT
10 *
11 ********************************
2017-08-27 13:02:58 +00:00
12
27-AUG-17 14:47
14
15 XC ; enable 65C02 code
2017-08-27 13:02:58 +00:00
16 DEBUG = 0
17 DO DEBUG
18 ORG $8000
19 ELSE
20 ORG $C800 ; Expansion ROM
2017-08-27 13:02:58 +00:00
21 FIN
22
23 * Memory defines
2017-08-27 13:02:58 +00:00
24
25 SLOT16 = $2B ; $s0 -> slot * 16
2017-08-27 13:02:58 +00:00
26 WORK = $3C
27 SLOT = $3D ; $0s
2017-08-27 13:02:58 +00:00
28 CMDLO = $40
29 CMDHI = $41
30
31 CURSLOT = $07F8 ; $Cs
2017-08-27 13:02:58 +00:00
32 DATA = $C080
33 CTRL = DATA+1
34 DIV = DATA+2
35 SS = DATA+3
36 R30 = $0478
37 R31 = $04F8
38 R32 = $0578
39 R33 = $05F8
40
41 * Constants
42
43 DUMMY = $FF
44 FRX = $10 ; CTRL register
45 ECE = $04
46 SS0 = $01 ; SS register
47 WP = $20
48 CARDDET = $40
49 INITED = $80
50
51
52 * signature bytes
53
C800: A2 20 54 LDX #$20
C802: A0 00 55 LDY #$00
C804: A2 03 56 LDX #$03
C806: 86 3C 57 STX WORK
58
59 * find slot nr
60
61 DO DEBUG
62 LDA #$04
63 STA SLOT
64 LDA #$C4
65 STA CURSLOT
66 LDA #$40
67 STA SLOT16
68 ELSE
C808: 20 58 FF 69 JSR $FF58
C80B: BA 70 TSX
C80C: BD 00 01 71 LDA $0100,X
C80F: 29 0F 72 AND #$0F
C811: 85 3D 73 STA SLOT ; $0s
C813: 09 C0 74 ORA #$C0
C815: 8D F8 07 75 STA CURSLOT ; $Cs
C818: 0A 76 ASL A
C819: 0A 77 ASL A
C81A: 0A 78 ASL A
C81B: 0A 79 ASL A
C81C: 85 2B 80 STA SLOT16 ; $s0
81 FIN
C81E: AA 82 TAX ; X holds now SLOT16
83
C81F: 2C FF CF 84 BIT $CFFF
C822: 20 00 C9 85 JSR INIT
86
87 *
88 * TODO: check for init error
89 *
90
91 ********************************
92 *
93 * Install SD card driver
94 *
95 ********************************
96
97 DO DEBUG
98
99 * see if slot has a driver already
100
101 LDX $BF31 ; get devcnt
102 INSTALL LDA $BF32,X ; get a devnum
103 AND #$70 ; isolate slot
104 CMP SLOT16 ; slot?
105 BEQ :INSOUT ; yes, skip it
106 DEX
107 BPL INSTALL ; keep up the search
108
109 * restore the devnum to the list
110
111 LDX $BF31 ; get devcnt again
112 CPX #$0D ; device table full?
113 BNE :INST2
114
115 JSR $FF3A ; bell
116 JMP :INSOUT ; do something!
117
118 :INST2 LDA $BF32-1,X ; move all entries down
119 STA $BF32,X ; to make room at front
120 DEX ; for a new entry
121 BNE :INST2
122 LDA #$04 ; ProFile type device
123 ORA SLOT16
124 STA $BF32 ; slot, drive 1 at top of list
125 INC $BF31 ; update devcnt
126
127 * now insert the device driver vector
128
129 LDA SLOT
130 ASL
131 TAX
132 LDA #<DRIVER
133 STA $BF10,X ; write to driver table
134 LDA #>DRIVER
135 STA $BF11,X
136 :INSOUT RTS
137
138
139 ********************************
140 *
141 * Boot from SD card
142 *
143 ********************************
144
145 ELSE
146
C825: A9 01 147 BOOT LDA #$01
C827: 85 42 148 STA $42 ; load command
C829: A5 2B 149 LDA SLOT16
C82B: AA 150 TAX
C82C: 85 43 151 STA $43 ; slot number
C82E: 64 44 152 STZ $44 ; buffer lo
C830: A9 08 153 LDA #$08
C832: 85 45 154 STA $45 ; buffer hi
C834: 64 46 155 STZ $46 ; block lo
C836: 64 47 156 STZ $47 ; block hi
C838: 2C FF CF 157 BIT $CFFF
C83B: 20 AD CA 158 JSR READ ; call driver
C83E: 4C 01 08 159 JMP $801 ; goto bootloader
160
161 FIN
162
163
164 ********************************
165 *
166 * Jump table
167 *
168 ********************************
169
C841: D8 170 DRIVER CLD
171 DO DEBUG
172 LDA #$04
173 STA SLOT
174 LDA #$C4
175 STA CURSLOT
176 LDA #$40
177 STA SLOT16
178 ELSE
C842: 20 58 FF 179 JSR $FF58 ; find slot nr
C845: BA 180 TSX
C846: BD 00 01 181 LDA $0100,X
C849: 29 0F 182 AND #$0F
C84B: 85 3D 183 STA SLOT ; $0s
C84D: 09 C0 184 ORA #$C0
C84F: 8D F8 07 185 STA CURSLOT ; $Cs
C852: 0A 186 ASL A
C853: 0A 187 ASL A
C854: 0A 188 ASL A
C855: 0A 189 ASL A
C856: 85 2B 190 STA SLOT16 ; $s0
191 FIN
C858: AA 192 TAX ; X holds now SLOT16
193
C859: 2C FF CF 194 BIT $CFFF
C85C: A9 80 195 LDA #INITED ; check for init
C85E: 3C 83 C0 196 BIT SS,X
C861: F0 22 197 BEQ :INIT
198
C863: A5 42 199 :CMD LDA $42 ; get command
C865: C9 00 200 CMP #$00
C867: F0 10 201 BEQ :STATUS
C869: C9 01 202 CMP #$01
C86B: F0 0F 203 BEQ :READ
C86D: C9 02 204 CMP #$02
C86F: F0 0E 205 BEQ :WRITE
C871: C9 03 206 CMP #$03
C873: F0 0D 207 BEQ :FORMAT
C875: 38 208 SEC ; unknown command
C876: A9 01 209 LDA #$01
C878: 60 210 RTS
211
C879: 4C A5 CA 212 :STATUS JMP STATUS
C87C: 4C AD CA 213 :READ JMP READ
C87F: 4C 15 CB 214 :WRITE JMP WRITE
C882: 4C 8B CB 215 :FORMAT JMP FORMAT
C885: 20 00 C9 216 :INIT JSR INIT
C888: 80 D9 217 BRA :CMD
218
219
220 * Signature bytes
221
C88A: 00 00 00 222 DS \ ; fill with zeroes
C88D: 00 00 00 00
C891: 00 00 00 00
C895: 00 00 00 00
C899: 00 00 00 00
C89D: 00 00 00 00
C8A1: 00 00 00 00
C8A5: 00 00 00 00
C8A9: 00 00 00 00
C8AD: 00 00 00 00
C8B1: 00 00 00 00
C8B5: 00 00 00 00
C8B9: 00 00 00 00
C8BD: 00 00 00 00
C8C1: 00 00 00 00
C8C5: 00 00 00 00
C8C9: 00 00 00 00
C8CD: 00 00 00 00
C8D1: 00 00 00 00
C8D5: 00 00 00 00
C8D9: 00 00 00 00
C8DD: 00 00 00 00
C8E1: 00 00 00 00
C8E5: 00 00 00 00
C8E9: 00 00 00 00
C8ED: 00 00 00 00
C8F1: 00 00 00 00
C8F5: 00 00 00 00
C8F9: 00 00 00 00
C8FD: 00 00 00
223 DS -4 ; locate to $xxFC
C8FC: FF FF 224 DW $FFFF ; 65535 blocks
C8FE: 47 225 DB $47 ; Status bits
C8FF: 41 226 DB #<DRIVER ; LSB of driver
227
228
229 ********************************
230 *
231 * Initialize SD card
232 *
233 * C Clear - No error
234 * Set - Error
235 * A $00 - No error
236 * $27 - I/O error - Init failed
237 * $28 - No card inserted
238 *
239 ********************************
240
C900: D8 241 INIT CLD
C901: A9 03 242 LDA #$03 ; set SPI mode 3
C903: 9D 81 C0 243 STA CTRL,X
C906: BD 83 C0 244 LDA SS,X
C909: 09 01 245 ORA #SS0 ; set CS high
C90B: 9D 83 C0 246 STA SS,X
C90E: A9 07 247 LDA #7
C910: 9D 82 C0 248 STA DIV,X
C913: A0 0A 249 LDY #10
C915: A9 FF 250 LDA #DUMMY
251
C917: 9D 80 C0 252 :LOOP STA DATA,X
C91A: 3C 81 C0 253 :WAIT BIT CTRL,X
C91D: 10 FB 254 BPL :WAIT
C91F: 88 255 DEY
C920: D0 F5 256 BNE :LOOP ; do 10 times
C922: BD 83 C0 257 LDA SS,X
C925: 29 FE 258 AND #$FF!SS0 ; set CS low
C927: 9D 83 C0 259 STA SS,X
260
C92A: A9 8F 261 LDA #<CMD0 ; send CMD0
C92C: 85 40 262 STA CMDLO
C92E: A9 CB 263 LDA #>CMD0
C930: 85 41 264 STA CMDHI
C932: 20 F2 C9 265 JSR CMD
C935: 20 06 CA 266 JSR GETR1 ; get response
C938: C9 01 267 CMP #$01
C93A: D0 39 268 BNE :ERROR1 ; error!
269
C93C: A9 9B 270 LDA #<CMD8 ; send CMD8
C93E: 85 40 271 STA CMDLO
C940: A9 CB 272 LDA #>CMD8
C942: 85 41 273 STA CMDHI
C944: 20 F2 C9 274 JSR CMD
C947: 20 21 CA 275 JSR GETR3
C94A: C9 01 276 CMP #$01
C94C: D0 2A 277 BNE :SDV1 ; may be SD Ver. 1
278
279 * check for $01aa match!
C94E: A9 A7 280 :SDV2 LDA #<CMD55
C950: 85 40 281 STA CMDLO
C952: A9 CB 282 LDA #>CMD55
C954: 85 41 283 STA CMDHI
C956: 20 F2 C9 284 JSR CMD
C959: 20 06 CA 285 JSR GETR1
C95C: A9 AD 286 LDA #<ACMD4140
C95E: 85 40 287 STA CMDLO
C960: A9 CB 288 LDA #>ACMD4140
C962: 85 41 289 STA CMDHI
C964: 20 F2 C9 290 JSR CMD
C967: 20 06 CA 291 JSR GETR1
C96A: C9 01 292 CMP #$01
C96C: F0 E0 293 BEQ :SDV2 ; wait for ready
C96E: C9 00 294 CMP #$00
C970: D0 03 295 BNE :ERROR1 ; error!
296 * send CMD58
297 * SD Ver. 2 initialized!
C972: 4C B2 C9 298 JMP :BLOCKSZ
299
C975: 4C E0 C9 300 :ERROR1 JMP :IOERROR ; needed for far jump
301
C978: A9 A7 302 :SDV1 LDA #<CMD55
C97A: 85 40 303 STA CMDLO
C97C: A9 CB 304 LDA #>CMD55
C97E: 85 41 305 STA CMDHI
C980: 20 F2 C9 306 JSR CMD ; ignore response
C983: A9 B3 307 LDA #<ACMD410
C985: 85 40 308 STA CMDLO
C987: A9 CB 309 LDA #>ACMD410
C989: 85 41 310 STA CMDHI
C98B: 20 F2 C9 311 JSR CMD
C98E: 20 06 CA 312 JSR GETR1
C991: C9 01 313 CMP #$01
C993: F0 E3 314 BEQ :SDV1 ; wait for ready
C995: C9 00 315 CMP #$00
C997: D0 03 316 BNE :MMC ; may be MMC card
317 * SD Ver. 1 initialized!
C999: 4C B2 C9 318 JMP :BLOCKSZ
319
C99C: A9 95 320 :MMC LDA #<CMD1
C99E: 85 40 321 STA CMDLO
C9A0: A9 CB 322 LDA #>CMD1
C9A2: 85 41 323 STA CMDHI
C9A4: 20 F2 C9 324 :LOOP1 JSR CMD
C9A7: 20 06 CA 325 JSR GETR1
C9AA: C9 01 326 CMP #$01
C9AC: F0 F6 327 BEQ :LOOP1 ; wait for ready
C9AE: C9 00 328 CMP #$00
C9B0: D0 2E 329 BNE :IOERROR ; error!
330 * MMC Ver. 3 initialized!
331
C9B2: A9 A1 332 :BLOCKSZ LDA #<CMD16
C9B4: 85 40 333 STA CMDLO
C9B6: A9 CB 334 LDA #>CMD16
C9B8: 85 41 335 STA CMDHI
C9BA: 20 F2 C9 336 JSR CMD
C9BD: 20 06 CA 337 JSR GETR1
C9C0: C9 00 338 CMP #$00
C9C2: D0 1C 339 BNE :IOERROR ; error!
340
C9C4: A4 3D 341 :END LDY SLOT
C9C6: BD 83 C0 342 LDA SS,X
C9C9: 09 80 343 ORA #INITED ; initialized
C9CB: 9D 83 C0 344 STA SS,X
C9CE: BD 81 C0 345 LDA CTRL,X
C9D1: 09 04 346 ORA #ECE ; enable 7MHz
C9D3: 9D 81 C0 347 STA CTRL,X
C9D6: 18 348 CLC ; all ok
C9D7: A0 00 349 LDY #0
C9D9: 90 08 350 BCC :END1
C9DB: 38 351 :CDERROR SEC
C9DC: A0 28 352 LDY #$28 ; no card error
C9DE: B0 03 353 BCS :END1
C9E0: 38 354 :IOERROR SEC
C9E1: A0 27 355 LDY #$27 ; init error
C9E3: BD 83 C0 356 :END1 LDA SS,X ; set CS high
C9E6: 09 01 357 ORA #SS0
C9E8: 9D 83 C0 358 STA SS,X
C9EB: A9 00 359 LDA #0 ; set div to 2
C9ED: 9D 82 C0 360 STA DIV,X
C9F0: 98 361 TYA ; retval in A
C9F1: 60 362 RTS
363
364
365 ********************************
366 *
367 * Send SD command
368 * Call with command in CMDHI and CMDLO
369 *
370 ********************************
371
C9F2: 5A 372 CMD PHY
C9F3: A0 00 373 LDY #0
C9F5: B1 40 374 :LOOP LDA (CMDLO),Y
C9F7: 9D 80 C0 375 STA DATA,X
C9FA: 3C 81 C0 376 :WAIT BIT CTRL,X ; TC is in N
C9FD: 10 FB 377 BPL :WAIT
C9FF: C8 378 INY
CA00: C0 06 379 CPY #6
CA02: 90 F1 380 BCC :LOOP
CA04: 7A 381 PLY
CA05: 60 382 RTS
383
384
385 ********************************
386 *
387 * Get R1
388 * R1 is in A
389 *
390 ********************************
391
CA06: A9 FF 392 GETR1 LDA #DUMMY
CA08: 9D 80 C0 393 STA DATA,X
CA0B: 3C 81 C0 394 :WAIT BIT CTRL,X
CA0E: 10 FB 395 BPL :WAIT
CA10: BD 80 C0 396 LDA DATA,X ; get response
CA13: 85 3C 397 STA WORK ; save R1
CA15: 29 80 398 AND #$80
CA17: D0 ED 399 BNE GETR1 ; wait for MSB=0
CA19: A9 FF 400 LDA #DUMMY
CA1B: 9D 80 C0 401 STA DATA,X ; send another dummy
CA1E: A5 3C 402 LDA WORK ; restore R1
CA20: 60 403 RTS
404
405
406 ********************************
2017-08-27 13:02:58 +00:00
407 *
408 * Get R3
409 * R1 is in A
410 * R3 is in scratchpad ram
411 *
412 ********************************
413
CA21: 20 06 CA 414 GETR3 JSR GETR1 ; get R1 first
CA24: 48 415 PHA ; save R1
CA25: 5A 416 PHY ; save Y
CA26: A0 04 417 LDY #04 ; load counter
CA28: A9 FF 418 :LOOP LDA #DUMMY ; send dummy
CA2A: 9D 80 C0 419 STA DATA,X
CA2D: 3C 81 C0 420 :WAIT BIT CTRL,X
CA30: 10 FB 421 BPL :WAIT
CA32: BD 80 C0 422 LDA DATA,X
CA35: 48 423 PHA
CA36: 88 424 DEY
CA37: D0 EF 425 BNE :LOOP ; do 4 times
CA39: A4 3D 426 LDY SLOT
CA3B: 68 427 PLA
CA3C: 99 F8 05 428 STA R33,Y ; save R3
CA3F: 68 429 PLA
CA40: 99 78 05 430 STA R32,Y
CA43: 68 431 PLA
CA44: 99 F8 04 432 STA R31,Y
CA47: 68 433 PLA
CA48: 99 78 04 434 STA R30,Y
CA4B: 7A 435 PLY ; restore Y
CA4C: A9 FF 436 LDA #DUMMY
CA4E: 9D 80 C0 437 STA DATA,X ; send another dummy
CA51: 68 438 PLA ; restore R1
CA52: 60 439 RTS
440
441
442 ********************************
2017-08-27 13:02:58 +00:00
443 *
444 * Calculate block address
445 * Block no is in $46-47
446 * Address is in R30-R33
447 *
448 ********************************
449
CA53: DA 450 BLOCK PHX ; save X
CA54: 5A 451 PHY ; save Y
CA55: A6 3D 452 LDX SLOT
CA57: A5 46 453 LDA $46 ; store block num
CA59: 9D F8 05 454 STA R33,X ; in R30-R33
CA5C: A5 47 455 LDA $47
CA5E: 9D 78 05 456 STA R32,X
CA61: A9 00 457 LDA #0
CA63: 9D F8 04 458 STA R31,X
CA66: 9D 78 04 459 STA R30,X
460
CA69: A0 09 461 LDY #9 ; ASL can't be used with Y
CA6B: 1E F8 05 462 :LOOP ASL R33,X ; mul block num
CA6E: 3E 78 05 463 ROL R32,X ; by 512 to get
CA71: 3E F8 04 464 ROL R31,X ; real address
CA74: 3E 78 04 465 ROL R30,X
CA77: 88 466 DEY
CA78: D0 F1 467 BNE :LOOP
CA7A: 7A 468 PLY ; restore Y
CA7B: FA 469 PLX ; restore X
CA7C: 60 470 RTS
471
472
473 ********************************
474 *
475 * Send SD command
476 * Cmd is in A
477 *
478 ********************************
479
CA7D: 5A 480 COMMAND PHY ; save Y
CA7E: A4 3D 481 LDY SLOT
CA80: 9D 80 C0 482 STA DATA,X ; send command
CA83: B9 78 04 483 LDA R30,Y ; get arg from R30 on
CA86: 9D 80 C0 484 STA DATA,X
CA89: B9 F8 04 485 LDA R31,Y
CA8C: 9D 80 C0 486 STA DATA,X
CA8F: B9 78 05 487 LDA R32,Y
CA92: 9D 80 C0 488 STA DATA,X
CA95: B9 F8 05 489 LDA R33,Y
CA98: 9D 80 C0 490 STA DATA,X
CA9B: A9 FF 491 LDA #DUMMY
CA9D: 9D 80 C0 492 STA DATA,X ; dummy crc
CAA0: 20 06 CA 493 JSR GETR1
CAA3: 7A 494 PLY ; restore Y
CAA4: 60 495 RTS
496
497
498 ********************************
499 *
500 * Status request
501 * $43 Unit number DSSS000
502 * $44-45 Unused
503 * $46-47 Unused
504 *
505 * C Clear - No error
506 * Set - Error
507 * A $00 - No error
508 * $27 - I/O error
509 * $28 - No card inserted / no init
510 * $2B - Card write protected
511 * x - Blocks avail (low byte)
512 * y - Blocks avail (high byte)
513 *
514 ********************************
515
CAA5: 18 516 STATUS CLC ; no error
CAA6: A9 00 517 LDA #0
CAA8: A2 FF 518 LDX #$FF ; 32 MB partition
CAAA: A0 FF 519 LDY #$FF
CAAC: 60 520 RTS
521
522 * TODO: check for card detect and write protect!
523
524
525 ********************************
526 *
527 * Read 512 byte block
528 * $43 Unit number DSSS0000
529 * $44-45 Address (LO/HI) of buffer
530 * $46-47 Block number (LO/HI)
531 *
2017-08-27 13:02:58 +00:00
532 * C Clear - No error
533 * Set - Error
534 * A $00 - No error
535 * $27 - Bad block number
536 * $28 - No card inserted
537 *
538 ********************************
539
540 * TODO: check for card detect!
541
CAAD: 20 53 CA 542 READ JSR BLOCK ; calc block address
543
CAB0: BD 83 C0 544 LDA SS,X ; enable /CS
CAB3: 29 FE 545 AND #$FF!SS0
CAB5: 9D 83 C0 546 STA SS,X
CAB8: A9 51 547 LDA #$51 ; send CMD17
CABA: 20 7D CA 548 JSR COMMAND ; send command
549
CABD: C9 00 550 CMP #0 ; check for error
CABF: D0 48 551 BNE :ERROR
552
CAC1: A9 FF 553 :GETTOK LDA #DUMMY ; get data token
CAC3: 9D 80 C0 554 STA DATA,X
CAC6: BD 80 C0 555 LDA DATA,X ; get response
CAC9: C9 FE 556 CMP #$FE
CACB: D0 F4 557 BNE :GETTOK ; wait for $FE
558
CACD: A0 02 559 LDY #2 ; read data from card
CACF: BD 81 C0 560 LDA CTRL,X ; enable FRX
CAD2: 09 10 561 ORA #FRX
CAD4: 9D 81 C0 562 STA CTRL,X
CAD7: A9 FF 563 LDA #DUMMY
CAD9: 9D 80 C0 564 STA DATA,X
CADC: 64 3C 565 :LOOPY STZ WORK
CADE: BD 80 C0 566 :LOOPW LDA DATA,X
CAE1: 92 44 567 STA ($44)
CAE3: E6 44 568 INC $44
CAE5: D0 02 569 BNE :INW
CAE7: E6 45 570 INC $45 ; inc msb on page boundary
CAE9: E6 3C 571 :INW INC WORK
CAEB: D0 F1 572 BNE :LOOPW
CAED: 88 573 DEY
CAEE: D0 EC 574 BNE :LOOPY
575
CAF0: BD 81 C0 576 LDA CTRL,X ; disable FRX
CAF3: 29 EF 577 AND #$FF!FRX
CAF5: 9D 81 C0 578 STA CTRL,X
579
CAF8: A9 FF 580 :CRC LDA #DUMMY ; first crc byte has
CAFA: 9D 80 C0 581 STA DATA,X ; already been read
582
CAFD: BD 83 C0 583 LDA SS,X
CB00: 09 01 584 ORA #SS0
CB02: 9D 83 C0 585 STA SS,X ; disable /CS
CB05: 18 586 CLC ; no error
CB06: A9 00 587 LDA #$00
CB08: 60 588 RTS
589
CB09: BD 83 C0 590 :ERROR LDA SS,X
CB0C: 09 01 591 ORA #SS0
CB0E: 9D 83 C0 592 STA SS,X ; disable /CS
CB11: 38 593 SEC ; an error occured
CB12: A9 27 594 LDA #$27
CB14: 60 595 RTS
596
597
598 ********************************
599 *
600 * Write 512 byte block
601 * $43 Unit number DSSS000
602 * $44-45 Address (LO/HI) of buffer
603 * $46-47 Block number (LO/HI)
604 *
605 * C Clear - No error
606 * Set - Error
607 * A $00 - No error
608 * $27 - I/O error or bad block number
609 * $28 - No card inserted
610 * $2B - Card write protected
611 *
612 ********************************
613
614 * TODO: check for card detect and write protect!
615
CB15: 20 53 CA 616 WRITE JSR BLOCK ; calc block address
617
CB18: BD 83 C0 618 LDA SS,X ; enable /CS
CB1B: 29 FE 619 AND #$FF!SS0
CB1D: 9D 83 C0 620 STA SS,X
CB20: A9 58 621 LDA #$58 ; send CMD24
CB22: 20 7D CA 622 JSR COMMAND ; send command
623
CB25: C9 00 624 CMP #0 ; check for error
CB27: D0 4A 625 BNE :ERROR
626
CB29: A9 FF 627 LDA #DUMMY
CB2B: 9D 80 C0 628 STA DATA,X ; send dummy
CB2E: A9 FE 629 LDA #$FE
CB30: 9D 80 C0 630 STA DATA,X ; send data token
631
CB33: A0 02 632 LDY #2 ; send data to card
CB35: 64 3C 633 :LOOPY STZ WORK
CB37: B2 44 634 :LOOPW LDA ($44)
CB39: 9D 80 C0 635 STA DATA,X
CB3C: E6 44 636 INC $44
CB3E: D0 02 637 BNE :INW
CB40: E6 45 638 INC $45 ; inc msb on page boundary
CB42: E6 3C 639 :INW INC WORK
CB44: D0 F1 640 BNE :LOOPW
CB46: 88 641 DEY
CB47: D0 EC 642 BNE :LOOPY
643
CB49: 9D 80 C0 644 :CRC STA DATA,X ; send 2 dummy crc bytes
CB4C: 9D 80 C0 645 STA DATA,X
646
CB4F: 9D 80 C0 647 STA DATA,X ; get data response
CB52: BD 80 C0 648 LDA DATA,X
CB55: 29 1F 649 AND #$1F
CB57: C9 05 650 CMP #$05
CB59: D0 18 651 BNE :ERROR ; check for write error
652
CB5B: A9 FF 653 :WAIT6 LDA #DUMMY
CB5D: 9D 80 C0 654 STA DATA,X ; wait for write cycle
CB60: BD 80 C0 655 LDA DATA,X ; to complete
CB63: C9 00 656 CMP #$00
CB65: F0 F4 657 BEQ :WAIT6
658
CB67: BD 83 C0 659 LDA SS,X ; disable /CS
CB6A: 09 01 660 ORA #SS0
CB6C: 9D 83 C0 661 STA SS,X
CB6F: 18 662 CLC ; no error
CB70: A9 00 663 LDA #0
CB72: 60 664 RTS
665
CB73: A9 FF 666 :ERROR LDA #DUMMY
CB75: 9D 80 C0 667 STA DATA,X ; wait for write cycle
CB78: BD 80 C0 668 LDA DATA,X ; to complete
CB7B: C9 00 669 CMP #$00
CB7D: F0 F4 670 BEQ :ERROR
671
CB7F: BD 83 C0 672 LDA SS,X
CB82: 09 01 673 ORA #SS0
CB84: 9D 83 C0 674 STA SS,X ; disable /CS
CB87: 38 675 SEC ; an error occured
CB88: A9 27 676 LDA #$27
CB8A: 60 677 RTS
678
679
680 ********************************
681 *
682 * Format
683 * not supported!
684 *
685 ********************************
686
CB8B: 38 687 FORMAT SEC
CB8C: A9 01 688 LDA #$01 ; invalid command
CB8E: 60 689 RTS
690
691
CB8F: 40 00 00 692 CMD0 HEX 400000
CB92: 00 00 95 693 HEX 000095
CB95: 41 00 00 694 CMD1 HEX 410000
CB98: 00 00 F9 695 HEX 0000F9
CB9B: 48 00 00 696 CMD8 HEX 480000
CB9E: 01 AA 87 697 HEX 01AA87
CBA1: 50 00 00 698 CMD16 HEX 500000
CBA4: 02 00 FF 699 HEX 0200FF
CBA7: 77 00 00 700 CMD55 HEX 770000
CBAA: 00 00 65 701 HEX 000065
CBAD: 69 40 00 702 ACMD4140 HEX 694000
CBB0: 00 00 77 703 HEX 000077
CBB3: 69 00 00 704 ACMD410 HEX 690000
CBB6: 00 00 FF 705 HEX 0000FF
2017-08-27 13:02:58 +00:00
--End assembly, 953 bytes, Errors: 0
2017-08-27 13:02:58 +00:00
Symbol table - alphabetical order:
2017-08-27 13:02:58 +00:00
ACMD410 =$CBB3 ACMD4140=$CBAD BLOCK =$CA53 ? BOOT =$C825
? CARDDET =$40 CMD =$C9F2 CMD0 =$CB8F CMD1 =$CB95
CMD16 =$CBA1 CMD55 =$CBA7 CMD8 =$CB9B CMDHI =$41
CMDLO =$40 COMMAND =$CA7D CTRL =$C081 CURSLOT =$07F8
DATA =$C080 DEBUG =$00 DIV =$C082 DRIVER =$C841
DUMMY =$FF ECE =$04 FORMAT =$CB8B FRX =$10
GETR1 =$CA06 GETR3 =$CA21 INIT =$C900 INITED =$80
R30 =$0478 R31 =$04F8 R32 =$0578 R33 =$05F8
READ =$CAAD SLOT =$3D SLOT16 =$2B SS =$C083
SS0 =$01 STATUS =$CAA5 WORK =$3C ? WP =$20
WRITE =$CB15
Symbol table - numerical order:
2017-08-27 13:02:58 +00:00
DEBUG =$00 SS0 =$01 ECE =$04 FRX =$10
? WP =$20 SLOT16 =$2B WORK =$3C SLOT =$3D
CMDLO =$40 ? CARDDET =$40 CMDHI =$41 INITED =$80
DUMMY =$FF R30 =$0478 R31 =$04F8 R32 =$0578
R33 =$05F8 CURSLOT =$07F8 DATA =$C080 CTRL =$C081
DIV =$C082 SS =$C083 ? BOOT =$C825 DRIVER =$C841
INIT =$C900 CMD =$C9F2 GETR1 =$CA06 GETR3 =$CA21
BLOCK =$CA53 COMMAND =$CA7D STATUS =$CAA5 READ =$CAAD
WRITE =$CB15 FORMAT =$CB8B CMD0 =$CB8F CMD1 =$CB95
CMD8 =$CB9B CMD16 =$CBA1 CMD55 =$CBA7 ACMD4140=$CBAD
ACMD410 =$CBB3