Submitted by Steve Fewell
Routine:Get Filename
Name: Get Filename and set parameter block Filename and Load address
Starting Address: &BE41
Entry criteria: BASIC Text Pointer A points to a String expression.
Exit: X and Y contain the High Order address (X = MSB). &3B-&3C = the High Order address.
Description:
[BE41] Call &BE36 to do the following:
* Set BASIC Text Pointer B offset to BASIC Text Pointer A offset.
* Get result of expression at BASIC Text Pointer B.
* Issue 'Type mismatch' error if the result is not a String value.
* Call routine &BE25 to Store a carriage return (#&0D) character at the end of the String, and to set &37-&38
to point the the SWA address (&0600).
* Call &9B91 to check that the Statement is terminated correctly.
This obtains the filename specified and appends a <CR> to the end of the name, so that the filename is in the correct
MOS format - ready for an operating system call to OSFILE (&FFDD) [which requires a <cr> to terminate the filename].
The OSFILE parameter block filename address field (&37-&38) is set to point to the filename (located in the SWA).
Store the Ptr A Offset value (in Y) minus 1 in location &39 - this value will be &00, as the Check end of statement
routine resets the PTR A offset to 1. This is the load address (LSB) parameter in the OSFILE parameter block.
Store &18 (PAGE -> MSB Byte) in location &3A. This is file load address (MSB) parameter in the OSFILE parameter block.
[BE4B] Read the Machine's High Order address (OSBYTE call #&82).
If no memory extensions are in place, the High order address will be &FFFF.
Store the High Order address in locations &3B-&3C (high byte first).
This sets the High Order location of the Load address in the OSFILE parameter block.
(now, locations &39-&3C contain the complete load address for the file).
BE33 | L | 076 146 144 | 4C 92 90 | JMP &9092 Type mismatch error |
BE36 | / | 032 047 157 | 20 2F 9D | JSR &9D2F Ptr B = Ptr A & Get result of expression |
BE39 | 208 248 | D0 F8 | BNE -8 --> &BE33 | |
BE3B | % | 032 037 190 | 20 25 BE | JSR &BE25 Store #&0D (Carriage Return) at end of SWA |
BE3E | L | 076 145 155 | 4C 91 9B | JMP &9B91 X = A; Check for end of Statement (PTR B) |
BE41 | 6 | 032 054 190 | 20 36 BE | JSR &BE36 Get filename |
BE44 | 136 | 88 | DEY | |
BE45 | 9 | 132 057 | 84 39 | STY &39 |
BE47 | 165 024 | A5 18 | LDA &18 | |
BE49 | : | 133 058 | 85 3A | STA &3A |
BE4B | 169 130 | A9 82 | LDA#&82 | |
BE4D | 032 244 255 | 20 F4 FF | JSR &FFF4 OSBYTE | |
BE50 | ; | 134 059 | 86 3B | STX &3B |
BE52 | < | 132 060 | 84 3C | STY &3C |
BE54 | ` | 096 | 60 | RTS |