A BASIC program to load a binary file

The simplest method to load a executable binary file using BASIC is:

10 memory <addr>-1
20 load"<filename>",<addr>
30 call <execution address>
where <addr> is the load address of the binary file, <filename> is the name of the binary file and <execution address> is the address to start the program from. e.g.
10 memory &1fff
20 load"demo.bin",&2000
30 call &3a56

Here, "demo.bin" is a binary file starting at &2000 with a execution address of &3a56.

If the code above is used, the minimum memory address that the file can be loaded to is &1173, without the "Memory full" error.

The above program can be improved to allow for a lower minimum memory address:

10 openout"d"
20 memory <addr>-1
20 closeout
30 load"<filename>",<addr>
40 call <execution address>

The minimum memory address now becomes &1a0.

NOTE:

The main advantage of a BASIC program to load a binary file is: