Format of LOAD"$" data

All aspects of programming on the Commander X16.
Post Reply
unartic
Posts: 145
Joined: Sat Oct 28, 2023 3:26 pm

Format of LOAD"$" data

Post by unartic »

Hi!

I've got some assemlby that loads the LOAD"$" equivalent into a part of memory, from which I now want to interpret the data.

Filename and blocksize is recognizable, but the rest of the data is not clear what it means. Nor how they files are seperated. It seems to be a $0 but, not always. I've included a screenshot of the debug window with the memory starting at $0811

I'm not able to find the specifications on the internet.

Can anyone help? :-)

Image
User avatar
desertfish
Posts: 1123
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Format of LOAD"$" data

Post by desertfish »

The format is identical to a BASIC program. Line numbers are the block counts, and every line ends with 0 byte. I also think there's some pointer bytes that you can skip which are used in BASIC to point to the next line or something.

Anyway if you search around for how BASIC programs are stored in memory you're off to the races with this too
TomXP411
Posts: 1804
Joined: Tue May 19, 2020 8:49 pm

Re: Format of LOAD"$" data

Post by TomXP411 »

Somewhere in here, I have a BASIC program that reads a directory.

The general format for each line is something like:
  • 2 bytes: throw away
  • 2 bytes: line number (file size) in blocks. (1 block is 254 bytes)
  • some spaces
  • quote
  • filename
  • quote
  • some spaces
  • PRG
  • zero
So you can read each filename by:
  • read and discard 2 bytes
  • read 2 bytes and convert to integer
  • read text to byte 0
And when you encounter a line that's just two zeroes, that's the end of the listing.
Post Reply