base:loading_a_file
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | base:loading_a_file [2015-04-17 04:32] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Loading a file to memory at address stored in file ====== | ||
+ | BASIC code: | ||
+ | < | ||
+ | LOAD "JUST A FILENAME", | ||
+ | </ | ||
+ | Assembler code: | ||
+ | < | ||
+ | LDA # | ||
+ | LDX #<fname | ||
+ | LDY #>fname | ||
+ | JSR $FFBD ; call SETNAM | ||
+ | LDA #$01 | ||
+ | LDX $BA ; last used device number | ||
+ | BNE .skip | ||
+ | LDX #$08 ; default to device 8 | ||
+ | .skip LDY #$01 ; not $01 means: load to address stored in file | ||
+ | JSR $FFBA ; call SETLFS | ||
+ | |||
+ | LDA #$00 ; $00 means: load to memory (not verify) | ||
+ | JSR $FFD5 ; call LOAD | ||
+ | BCS .error | ||
+ | RTS | ||
+ | .error | ||
+ | ; Accumulator contains BASIC error code | ||
+ | |||
+ | ; most likely errors: | ||
+ | ; A = $05 (DEVICE NOT PRESENT) | ||
+ | ; A = $04 (FILE NOT FOUND) | ||
+ | ; A = $1D (LOAD ERROR) | ||
+ | ; A = $00 (BREAK, RUN/STOP has been pressed during loading) | ||
+ | |||
+ | ... error handling ... | ||
+ | RTS | ||
+ | |||
+ | fname: | ||
+ | fname_end: | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ====== Loading a file to memory at a specified address====== | ||
+ | BASIC code: | ||
+ | < | ||
+ | LOAD "JUST A FILENAME", | ||
+ | </ | ||
+ | Assembler code: | ||
+ | < | ||
+ | load_address = $2000 ; just an example | ||
+ | |||
+ | LDA # | ||
+ | LDX #<fname | ||
+ | LDY #>fname | ||
+ | JSR $FFBD ; call SETNAM | ||
+ | LDA #$01 | ||
+ | LDX $BA ; last used device number | ||
+ | BNE .skip | ||
+ | LDX #$08 ; default to device 8 | ||
+ | .skip LDY #$00 ; $00 means: load to new address | ||
+ | JSR $FFBA ; call SETLFS | ||
+ | |||
+ | LDX #< | ||
+ | LDY #> | ||
+ | LDA #$00 ; $00 means: load to memory (not verify) | ||
+ | JSR $FFD5 ; call LOAD | ||
+ | BCS .error | ||
+ | RTS | ||
+ | .error | ||
+ | ; Accumulator contains BASIC error code | ||
+ | |||
+ | ; most likely errors: | ||
+ | ; A = $05 (DEVICE NOT PRESENT) | ||
+ | ; A = $04 (FILE NOT FOUND) | ||
+ | ; A = $1D (LOAD ERROR) | ||
+ | ; A = $00 (BREAK, RUN/STOP has been pressed during loading) | ||
+ | |||
+ | ... error handling ... | ||
+ | RTS | ||
+ | |||
+ | fname: | ||
+ | fname_end: | ||
+ | </ | ||
base/loading_a_file.txt · Last modified: 2015-04-17 04:32 by 127.0.0.1