How to create a ROM, BIN or CAS file

Gilbert Francois Duivesteijn

< Back to main page

When programming and compiling your assembly program, you have to choose how the program will be distributed. For each medium, the compiled binary requires a special header and sometimes a special footer.

ROM

The most simple template for creating a binary for a cartridge is given below. Note that the footer is there to pad the cartridge with value FF at the end of the binary, to give it a fixed file size. In this case, the ROM file is $4000 bytes, 16kB.

BIN

A BIN file can be loaded and started automatically with bload"myfile.bin",r from disk. The header contains the beginning -, end - and execution addresses of the binary. Unlike the ROM, the BIN format does not require padding at the end.

CAS

The CAS template has the most complicated header file. The last part of the header is similar to that of the BIN template, but there are more magic numbers and the filename is included in the header. Note that the filename can contain only 6 characters.

I reverse engineered these 3 lines of magic numbers by using the TAPE2CAS tool and dhex. Until now it always worked for me but I cannot guarantee that it is a generic, always working solution.