Zero-page memory maps of the PET that I've found claim that the zero page address range$00C2..$00D9
are used for static data, e.g. http://www.classiccmp.org/dunfield/pet/petmem.txt says:
RIDATA 00C2 Cassette Temp (64#00AA) read flags: 0=scan,
1-15=count, $40=load, $80=end of tape marker
RIPRTY 00C3 Cassette Short Cnt (64#00AB): counter of seconds
before tape write / checksum
PNT 00C4-00C5 Pointer: Current Screen Line Address
PNTR 00C6 Cursor Column on Current Line
SAL 00C7-00C8 Pointer: Tape Buffer/ Screen Scrolling
EAL 00C9-00CA Tape End Addresses/End of Program
CMP0 00CB-00CC Tape Timing Constants
QTSW 00CD Flag: Editor in Quote Mode, $00 = NO
BITTS 00CE Cassette Temp (64#00B4): Tape read timer flag
=IRQ enabled for Timer 1
00CF End of tape read
00D0 Read character error
FNLEN 00D1 Length of Current File Name
LA 00D2 Current Logical File Number
SA 00D3 Current Secondary Address
FA 00D4 Current Device Number
LNMX 00D5 Physical Screen Line Length
00D5 4.80: right side of window
TAPE1 00D6-00D7 Pointer: Start of Tape Buffer
TBLX 00D8 Current Cursor Physical Line Number
DATAX 00D9 Current Character to Print
However, looking at the ROM disassembly, one can find places where the address $00C2
is jumped to, e.g. http://www.zimmers.net/anonftp/pub/cbm/firmware/computers/pet/d/rom-1.html#C70A :
C70A 4C C2 00 JMP iC2
Looking at a disassembly starting at $00C2
after booting up a PET, I can see reasonable-looking code:
.C:00c2 E6 C9 INC $C9
.C:00c4 D0 02 BNE $00C8
.C:00c6 E6 CA INC $CA
.C:00c8 AD 00 04 LDA $0400
.C:00cb C9 3A CMP #$3A
.C:00cd B0 0A BCS $00D9
.C:00cf C9 20 CMP #$20
.C:00d1 F0 EF BEQ $00C2
.C:00d3 38 SEC
.C:00d4 E9 30 SBC #$30
.C:00d6 38 SEC
.C:00d7 E9 D0 SBC #$D0
.C:00d9 60 RTS
What is this area used for? Where is the code that assembles this program into this area? What's this code supposed to do? (It seems to be scanning the area starting at $0400
for :
and characters?)
It's part of the BASIC interpreter loop. It reads one byte of the tokenized BASIC program, setting zero flag if it's a colon or a zero byte and clearing the carry if it's a number. You can see it used in the main part of the interpreter loop at address C6B5.
I'm not sure why this routine was placed in zero page. It's a cycle (or rarely two) faster to use
LDA $0400
overLDA ($C9),Y
, but I can't see it actually making much difference.I should also note that the ROM disassembly you're looking at appears to be for a BASIC 1.0 ROM, while the memory map you've referenced is for versions 2.0 and 4.0.
Here's what Mapping the Commodore 64 by Sheldon Leemon says about the equivalent C64 routine: