5

Most largish programs written for the Commodore PET have a bunch of rem statements somewhere around the 8K or 16K area. The normal comment is something to do with a hole in memory. I remember PET programs crashing when I removed it. I used the CBM 4032 and CBM 8032 but never tried removing the REM statements to see if the problem had been fixed. Wish I had.

Two questions:

  1. What is this memory gap? Is it something like an address that has no memory?
  2. Did this problem propagate to the CBM 4032, CBM 8032, VIC-20 and Commodore 64?

Edit

The other possibility is an overlap, where the address of the end of one chip overlapped with the address of the start of the next chip.

Edit 2

Looking back at my old notes, it was on a PET 2001 with 32K memory and the REM statements had to be added around the 8K region.

12
  • 3
    And how does a REM statement in source code defend against access to non-existent memory?
    – dave
    Commented Feb 9 at 12:38
  • 1
    We had a 3032 at home and a Commodore 64. I do not recall ever seeing anything about a memory hole. I also read about and researched the PET extensively whilst writing my emulator and did not come across anything about a memory hole.
    – JeremyP
    Commented Feb 9 at 13:03
  • The contents of REM statements are ignored by BASIC when programs are run. This can be used to place what I guess you could consider a hole in which some binary data can go without it tripping up the BASIC interpreter. I know it was commonly used to store small chunks of machine language.
    – Brian
    Commented Feb 9 at 13:31
  • @Brian re The contents of REM statements are ignored by BASIC when programs are run. But apparently not ignored when it comes to them occupying memory. How do they manage to occupy the 'gap' in memory? How does the input statement get written to memory which it seems does not exist? If it truly does not exist, why is there no machine error when the REM statements are entered? How can BASIC read the statement to know it is a REM to be ignored?
    – dave
    Commented Feb 9 at 17:44
  • 1
    The PET RAM was notoriously unreliable, could it have been a machine-specific fix for bad bits? Commented Feb 10 at 4:37

2 Answers 2

4

I guess, this may be related to code overlays, where a new, task specific code segment is loaded from disk or tape to replace an existing one. This was a technique much more advertised for the PET than for any of the later models.

In order for this to work, the new segment has to exactly match the address range of the existing segment, otherwise, the link structure of the BASIC program (which is really a linked list, referencing the memory address of the respective next line) would be lost, and maybe any existing variable data (which follows immediately on top of the BASIC program in memory), as well. It would make sense to adjust for this by including REM statements, which would allow for minor modifications without a need to recreate all the other segments according to a new load address. (Mind that on the PET, all programs were loaded absolutely, just like with a secondary load address of "1" on the later 8-bit systems. Relative loading, i.e. the automatic relocation of BASIC programs, only became a thing with the VIC-20 and its different and also varying BASIC start address. So memory overlays may have been more "natural" to the PET environment. Moreover, PETs – apart from those with the very first ROM version – came with a built-in machine language monitor in ROM [dropped on later Commodore 8-bits to make room for color support], which would have facilitated saving dedicated RAM segments and made this technique more accessible.)

Anyways, the very fact of the removal of these REM statements leading to a corruption of these programs hints at self-modification by one mechanism or another. E.g., a short machine language routine may have been assembled from DATA statements into the locations reserved by a REM statement, which would inevitably result in memory corruption, if these statements would have been removed or changed in length. (A reason for doing it this way may have been to avoid the Scylla and Charybdis of the growing variable stack on the one side of free memory and the growing string stack from the other, top side, without a need to adjust for varying memory configurations. Notably, this wouldn't have been a thing on the C64, which already came with a full memory complement, but would have been an issue on the PET, which came in configurations of 8K, 16K, or 32K [and, initially, just 4K] of RAM.)

Edit, regarding the edit:

I may add, there is no way that multiple RAM chips may share the same address or may overlap in the address space. The PET features a continuous memory space for RAM from $0000 up to 32K (the lower half the available 64K address space.) Screen memory is 1K at $8000 and ROM is from $C000 to $FFFF with a gap for IO at $E800–$EFFF. All PETs but the original PET 2001 also feature a ROM slot required vor BASIC 4 at $B000–$BFFF and slots for option ROMs at $9000-$AFFF, thus mapping the entire 64K.

PETs also perform a RAM check at startup to determine the available RAM (which is why you see $AA for any empty, but initialized RAM, while unconnected addresses typically show the high-byte of that address, which is a quirk of the 6502. The original PET 2001 may also show some noise added to the high-nibble of any unconnected addresses.)

(The 6502 is actually quite finicky with the data bus and it's quite difficult to implement bank switching. Which is why the 6510 introduced dedicated port registers at $0000 and $0001.)

7
  • Wellcome to RC.SE :)
    – Raffzahn
    Commented Feb 14 at 16:25
  • 1
    I made it, finally… :-)
    – masswerk
    Commented Feb 14 at 17:52
  • Told you, we'll get you one day :))
    – Raffzahn
    Commented Feb 14 at 19:36
  • 1
    Got assimilated. Apparently not always a bad thing. :-)
    – masswerk
    Commented Feb 15 at 10:41
  • The fact that unconnected addresses show the high byte of the address isn't really a 6502 quirk, but rather a result of a floating data bus staying near the voltage level to which it was last driven. If one loads e.g. $FC and $FD with $12 and $34, respectively, and loads Y with $FF, and performs "LDA ($FC),Y", the last three memory operations would be fetchig $34 from address $FD, fetching whatever is on the bus (i.e. $34) from address $3411, and then fetching whatever is on the bus (still $34) from address $3511.
    – supercat
    Commented Feb 15 at 17:46
0

This seems mostly like a combination of a certain software structure relaying on program layout, like for machine code/data storage, and an imagined explanation.


Most largish programs written for the Commodore PET have a bunch of rem statements somewhere around the 8K or 16K area.

That would be completely new to me. Also, what means most? And which original PET (since you distinct it from 40/80xx) had more than 8 KiB?

The normal comment is something to do with a hole in memory.

Maybe less off a hole than creating one.

I remember PET programs crashing when I removed it.

That just means the program was sensitive about whats there - or location of other parts - as in using the REM lines as fixed address for machine programs and/or runtime data storage.

What is this memory gap? Is it something like an address that has no memory?

No such thing with PETs or any 6502 commodore, except for the VIC20.

The other possibility is an overlap, where the address of the end of one chip overlapped with the address of the start of the next chip.

Why on earth should anyone build a system faulty by design? Even less a company that price focused as Commodore.

12
  • 1
    "And which original PET (since you distinct it from 40/80xx) had more than 8 KiB?" Depends how you define "PET" but the 30xx series came in 16k and 32k versions. By that time, Commodore was calling them the CBM 3016 and CBM 3032 respectively, but everybody else called them "PET".
    – JeremyP
    Commented Feb 10 at 14:04
  • @JeremyP not in my memory.
    – Raffzahn
    Commented Feb 10 at 16:52
  • 1
    @Raffzahn - maybe your memory has a gap? ;-)
    – dave
    Commented Feb 10 at 17:40
  • @Raffzahn My parents bought a 3016. We called it a PET. Everybody called it a PET except Commodore.
    – JeremyP
    Commented Feb 11 at 15:14
  • @JeremyP might be something local, as everyone I know called them CBM , or just 3016 - PET was strictly only about the chicklet one. (also, you're just repeating yourself :))
    – Raffzahn
    Commented Feb 11 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .