I am studying assembly of the C64, and of course using VICE to do so. VICE has the load command to load data straight into the C64 RAM. I reckoned I could use that to put machine code into RAM and run it from there.

The weird thing now is that the load command seems to skip the first two bytes when loading data. I have this hex file:

[bf@localhost asm]$ hexdump -C test.hex 
00000000  01 02 03 04 05 06 07 08  09 0a 0b 0c 0d 0e 0f 10  |................|

But, when I load it into the RAM, it starts with byte with the value 03:

(C:$8170) load "/path/to/test.hex" 0 8000
Loading /path/to/test.hex from 8000
to 801D (1d bytes)
(C:$8170) m 8000
>C:8000  03 04 05 06  07 08 09 0a  0b 0c 0d 0e  0f 10 11 12   ................

Am I doing something wrong?

  • Perhaps that's the length? Try putting 01 00 and 00 01 as the first two bytes, and see what happens. (If I'm right, one of those is 1, and the other is 256.) It doesn't look like it, though. – wizzwizz4 Apr 3 at 11:57

Quote from VICE manual:

Load the specified file into memory. If no address is given, the file is loaded to the address specified by the first two bytes read from the file. If address is given, the file is loaded to the specified address and the first two bytes read from the file are skipped.

  • 7
    As to motivation here: this is exactly how files are stored natively on Commodores, it’s not a VICE invention. If you have any PRGs sitting around, which are direct file dumps rather than media images, then take a peek — you can even usually figure out which machine a PRG goes with from the loading address (and, on the Vic-20, with memory configuration), as all keep their BASIC programs at different addresses. – Tommy Apr 3 at 12:38
  • For C64 the first two bytes are usually 0x0801 which can be loaded with "x",8 as this is the default. – Devolus May 7 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.