base:sending_a_command_to_a_disk_drive
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | base:sending_a_command_to_a_disk_drive [2015-04-17 04:33] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Sending a command to a disk drive, the easy way ====== | ||
+ | |||
+ | The easiest way of sending a command to the disk drive is by simply using the command string as filename when calling OPEN. | ||
+ | |||
+ | BASIC code: | ||
+ | < | ||
+ | OPEN 15, | ||
+ | </ | ||
+ | Assembler code: | ||
+ | < | ||
+ | LDA # | ||
+ | LDX #<cmd | ||
+ | LDY #>cmd | ||
+ | JSR $FFBD ; call SETNAM | ||
+ | |||
+ | LDA #$0F ; file number 15 | ||
+ | LDX $BA ; last used device number | ||
+ | BNE .skip | ||
+ | LDX #$08 ; default to device 8 | ||
+ | .skip LDY #$0F ; secondary address 15 | ||
+ | JSR $FFBA ; call SETLFS | ||
+ | |||
+ | JSR $FFC0 ; call OPEN | ||
+ | BCS .error | ||
+ | .close | ||
+ | LDA #$0F ; filenumber 15 | ||
+ | JSR $FFC3 ; call CLOSE | ||
+ | |||
+ | JSR $FFCC ; call CLRCHN | ||
+ | RTS | ||
+ | .error | ||
+ | ; Akkumulator contains BASIC error code | ||
+ | |||
+ | ; most likely errors: | ||
+ | ; A = $05 (DEVICE NOT PRESENT) | ||
+ | |||
+ | ... error handling for open errors ... | ||
+ | JMP .close | ||
+ | |||
+ | cmd: .TEXT " | ||
+ | cmd_end: | ||
+ | </ | ||
+ | |||
+ | ====== Sending a command to a disk drive, the flexible way ====== | ||
+ | |||
+ | Another way of sending a command to the disk drive is by leaving the filename string empty and send the command string afterwards. The advantage of this is that you can send several commands but only open the command channel one time. | ||
+ | |||
+ | BASIC code: | ||
+ | < | ||
+ | OPEN 15, | ||
+ | </ | ||
+ | Assembler code: | ||
+ | < | ||
+ | LDA #$00 | ||
+ | LDX #$00 | ||
+ | LDY #$00 | ||
+ | JSR $FFBD ; call SETNAM (no filename) | ||
+ | |||
+ | LDA #$0F ; file number 15 | ||
+ | LDX $BA ; last used device number | ||
+ | BNE .skip | ||
+ | LDX #$08 ; default to device 8 | ||
+ | .skip LDY #$0F ; secondary address 15 | ||
+ | JSR $FFBA ; call SETLFS | ||
+ | |||
+ | JSR $FFC0 ; call OPEN | ||
+ | BCS .error | ||
+ | |||
+ | LDX #$0F ; filenumber 15 | ||
+ | JSR $FFC9 ; call CHKOUT (file 15 now used as output) | ||
+ | |||
+ | LDY #$00 | ||
+ | .loop LDA cmd,y ; get byte from command string | ||
+ | JSR $FFD2 ; call CHROUT (send byte through command channel) | ||
+ | INY | ||
+ | CPY # | ||
+ | BNE .loop | ||
+ | .close | ||
+ | LDA #$0F ; filenumber 15 | ||
+ | JSR $FFC3 ; call CLOSE | ||
+ | |||
+ | JSR $FFCC ; call CLRCHN | ||
+ | RTS | ||
+ | .error | ||
+ | ; Akkumulator contains BASIC error code | ||
+ | |||
+ | ; most likely errors: | ||
+ | ; A = $05 (DEVICE NOT PRESENT) | ||
+ | |||
+ | ... error handling for open errors ... | ||
+ | JMP .close | ||
+ | |||
+ | cmd: .TEXT " | ||
+ | .BYTE $0D ; carriage return, needed if more than one command is sent | ||
+ | cmd_end: | ||
+ | </ | ||
base/sending_a_command_to_a_disk_drive.txt · Last modified: 2015-04-17 04:33 by 127.0.0.1