# 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 name of the file in line 10 can be anything. It is never written, and the above program will function on a write protected disc

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

- If a executable binary program is RUN directly: e.g.

      RUN"demo.bin"

  Then it will be started with the firmware function "MC BOOT PROGRAM". This will reset the state of the firmware and disable the disc operating system. Therefore the selected drive and other disc operating system variables are lost.