Submitted by Steve Fewell
Description:
Call routine &BDE5 to check that the program can be read correctly. If it cannot be read then display the 'Bad program'
message and stop processing the SAVE command.
Call the routine &BE41 to obtain the filename (after the SAVE keyword) and append a '<cr>' character to the end
of the filename (so that the Operating System can identify the end of the name). It also checks that the SAVE statement has
been terminated correctly with an ':', '<cr>' or 'ELSE-token' character (or issue 'Syntax error' if not).
This routine sets locations &37-&38 to point to the filename (i.e. the SWA address - &0600), locations
&39-&3A to PAGE (setting the LSB byte to zero), i.e. the file load address, and locations &3B-&3C to the
Operating System High order address as ready by OSBYTE call #&82 (this value is usually &FFFF).
This completes the 32-bit load address for the file stored in locations &39-&3C.
On return from routine &BE41, X is the high byte for the Operating System High order address and Y is the low byte for
the 16-bit Operating System High order address.
Set &3D-&40 to value #&802B (with bytes &3F-&40 being the 16-bit Operating System High order address
returned in X and Y). This is the BASIC ROM access point, and the execution address for the file (i.e. the BASIC program's
execution address). This address doesn't, however, seem to have much use as there isn't a way to directly execute a BASIC
program from the Operating System / Filing System.
Set &41-&44 to PAGE (&18) (with byte &41 being zero and bytes &43-&44 being the 16-bit Operating
System High order address returned in X and Y). This is the start address for the data to save.
Set &45-&48 to TOP (&12-&13) (with bytes &47-&48 being the 16-bit Operating System High order address
returned in X and Y). This sets the end address of the data to save.
Set A to #&00 (this is the OSFILE (&FFDD) option for saving a block of memory to a file).
Set X to #&37 and Y to #&00 (this is the address of the parameter block for the OSFILE command - #&0037).
Call the OSFILE Operating System routine (&FFDD) to execute the file save.
Jump to &9005 to execute the next statement on the current command/program line (if any).
BE55 | 032 229 189 | 20 E5 BD | JSR &BDE5 Check program can be read correctly ('Bad program' message if not) | |
BE58 | A | 032 065 190 | 20 41 BE | JSR &BE41 Get Filename and set parameter block filename and load address |
BE5B | ? | 134 063 | 86 3F | STX &3F |
BE5D | @ | 132 064 | 84 40 | STY &40 |
BE5F | C | 134 067 | 86 43 | STX &43 |
BE61 | D | 132 068 | 84 44 | STY &44 |
BE63 | G | 134 071 | 86 47 | STX &47 |
BE65 | H | 132 072 | 84 48 | STY &48 |
BE67 | dA | 100 065 | 64 41 | STZ &41 |
BE69 | 166 018 | A6 12 | LDX &12 | |
BE6B | E | 134 069 | 86 45 | STX &45 |
BE6D | 166 019 | A6 13 | LDX &13 | |
BE6F | F | 134 070 | 86 46 | STX &46 |
BE71 | + | 162 043 | A2 2B | LDX#&2B |
BE73 | = | 134 061 | 86 3D | STX &3D |
BE75 | 162 128 | A2 80 | LDX#&80 | |
BE77 | > | 134 062 | 86 3E | STX &3E |
BE79 | 166 024 | A6 18 | LDX &18 | |
BE7B | B | 134 066 | 86 42 | STX &42 |
BE7D | 169 000 | A9 00 | LDA#&00 | |
BE7F | 168 | A8 | TAY | |
BE80 | 7 | 162 055 | A2 37 | LDX#&37 |
BE82 | 032 221 255 | 20 DD FF | JSR &FFDD OSFILE | |
BE85 | $ | 128 036 | 80 24 | BRA 36 --> &BEAB [JMP &9005 Execute next statement] |