5

On the Commodore 64, (and I believe also the VIC-20, PETs etc.) you may instruct BASIC to

LOAD "something",8

to load a file to the start of BASIC's area (and that address may vary between machines), or

LOAD "something",8,1

to load a file to the address specified in the first two bytes of the file. The former option was mostly used for BASIC programs, and of course the latter is mostly used for machine code (which is not usually written to be relocatable), and I guess bitmaps and other static data.

This goes for floppy disks, cassette tapes, hard disks, etc.

But since it doesn't really make sense to save a file in one way and load it again the other way, then the user needs to remember per file how to load it again. It seems much more sensible to me to have a bit in the metadata somewhere that specifies how to load the file. Is anything known or understood about why this wasn't done?

  • In case anybody else follows it as a potential lead: IEEE-488 "said nothing about the format of commands or data", per the group consensus on Wikipedia, at least. Also: 8,1 would work for loading BASIC on the same machine as saved it, as a proper BASIC address is in there, it's just that it'll be a function of model and memory size. – Tommy Apr 12 '18 at 12:19
8

Why did Commodore files not include metadata to say where in memory to load it?

They are there. Every saved memory content starts with two bytes noting the address it's taken from. No matter if disk or tape, if BASIC or machine code.

But since it doesn't really make sense to save a file in one way and load it again the other way, then the user needs to remember per file how to load it again.

It's not save it one way and load it another. Memory content, and that's true for machine or basic programs, are always saved with their start address stored as the first two bytes. And the way to load them to the same address they where saved is by using the secondary address 1 (*1). With this parameter the program gets loaded verbatim - exactly as saved. Without it gets relocated (and treated like a BASIC program).

There is no need to remember anything. Any BASIC program can also be loaded with or without - as long as it's on the same machine in the same configuration.

It seems much more sensible to me to have a bit in the metadata somewhere that specifies how to load the file.

And what would it be good for? With a fixed mechanism always loading a program into the area where they where saved isn't really flexible, is it?

Is anything known or understood about why this wasn't done?

It's all about making life easy for users by setting the machines BASIC start address as default load address. And as with all default mechanic, it is supposed to be the shorter notation.

Now users can load the most common files (BASIC programs) on any machine without fiddling with address changes. Different Commodore computers used different areas for BASIC programs (*2). With this default mechanism programs can (often) be exchanged between different machines (*3).

In fact, some machines even change the BASIC load address depending on the configuration. An unexpanded VIC20 loads programs at $1000, while with a 3 KiB extension it's $1200. With a fixed load address from the file saved people would no longer be able to use programs they've written before buying the 3 KiB expansion afterwards.

Beside changing the load address, loading without not only adapts the load address, but also relocates the program. Yes, there's a need for that, as Commodore BASIC is stored in tokenized memory format, and here every line is preceded by the address of the next line. To make a program work from a different start address the loader needs to go thru the program, after placing it in memory, and recalculate all line address (*4).


*1 - In fact it's not even a real secondary address, but only a marker for the loader to use the stored start address. The drive always gets opened with a secondary address of 96

*2 - For example classic PET at $0400, VIC-20 at $1000 or C64 at $0800.

*3 - Of course, only as long as only instructions are used that are common to both machines. DLOAD from a BASIC 4.0 CBM will not compute on a straight C64.

*4 - That's also the reason why a disk drive is able to deliver a directory listing as pseudo BASIC program, without knowing anything about the computer handling of BASIC memory it is connected to: The 'program' gets relocated, so it can be listed on any Commodore. No matter if it's a PET with an 8050, or the same 8050 connected to a way later designed VIC-20

  • 1
    The VIC-20 is worse, since the start of program memory moves for different expansion configurations. – Joe Apr 12 '18 at 19:52
  • When storing programs to tape, the secondary address given to the "save" command can be used to mark the file non-relocatable, and also to indicate whether the "load" command should quit if the file is encountered and the name doesn't match (an "end-of-tape" marker, of sorts). Such abilities were not extended to the disk drive, but the system made provision for them. I don't know whether locating a non-relocatable tape would set the end-of-program address the way loading a normal tape does, but being able to have programs that could be loaded without setting that address would be helpful. – supercat Apr 12 '18 at 21:26
3

Both tape and disk formats include the start address of the file. Tape formats, but not disk formats, also include a flag to force the file to be loaded at the address indicated on the tape regardless of the command used to load it, while disk formats did not.

When loading a BASIC program, it is generally desirable to have it load at the start of BASIC memory, regardless of the address from which it is saved. For example, on the VIC-20, if one types in a program without a memory-expansion unit and saves it, the start address will be 0x1000. If one then powers off the machine, inserts a 3K expander, and powers the machine back on, the start of BASIC memory will be 0x0400. If one wants to load the earlier-saved program, it will need to be loaded starting at 0x0400; loading it at address 0x1000 isn't likely to be useful.

It might have been helpful for disk files to include more of a header than just a two-byte start address. Adding a byte to indicate whether the file should be regarded as a BASIC program (in which case it should load at the beginning of BASIC memory, and it should update the end-of-BASIC-memory pointer once loading is complete) would have avoided some of the weirdness associated with using "LOAD" with binary files. The design Commodore used probably seemed reasonable at the time, however.

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.