TomW wrote:
*RUN doesn't set the OSFILE control block pointer correctly,
What OSFILE control block? *RUN isn't an OSFILE call, so there's no OSFILE control block for it to modify.
Quote:
However, if I press Break and try to load it again,
Try to
load it or try to
run it? Are you doing
*RUN loader or
*LOAD loader (enter) CALL &1900 ? Or even just
CALL &190 without even reloading it?
Quote:
Okay, after a reset CODE is being loaded at 1900 instead of E00 - not entirely sure what the root cause is (code_block is being modified by the OS while LOADER is being loaded). I'll look more into it in the morning.
How are you re-exectuing the loader code?
*RUN loader or
CALL &1900? If
CALL &1900 then you will be executing whatever happens to be left over in the memory there, along with a modified control block. The control block will hold the file information details of 'CODE' from when it was loaded the first time 'LOADER' was run. If 'CODE's load address is not &E00 then the first word in the control block will no longer be the &E00 that the source code specified. Also, if the 'CODE's execution address is not &E00 then the second word in the control block will not be the &E00 specified in the source code.
Do the load and execution addresses of 'CODE' happen to be &1900 ? In that case the OSFILE block will be left holding contents that instruct OSFILE to load a file to &1900, which is the action you are seeing.
Code:
Before calling OSFILE:
code_block: .byte <code_file_name, >code_file_name
.byte $00, $0e, $00, $00 ; I want to load to &E00
.byte $00, $0e, $00, $00 ; &00 = load to the address specified here
.byte $0b, $00, $00, $00
.byte $0b, $0e, $00, $00
After calling OSFILE:
code_block: .byte <code_file_name, >code_file_name
.byte $00, $19, $00, $00 ; load address of file just loaded
.byte $00, $19, $00, $00 ; exec address of file just loaded
.byte $0b, $00, $00, $00 ; length of file just loaded
.byte $00, $00, $00, $00 ; attributes of file just loaded
Resuse that OSFILE block without changing it:
code_block: .byte <code_file_name, >code_file_name
.byte $00, $19, $00, $00 ; I want to load to &1900
.byte $00, $19, $00, $00 ; &00 = load to address specified here
.byte $0b, $00, $00, $00
.byte $00, $00, $00, $00