Various VIC Memory Locations
Jim Wilcox, Vienna, WV
Editors Note: A Full VIC memory map will appear in the fall Home and Educational COMPUTING! issue. Here are some PEEKs and POKEs to get you started. Descriptions in parentheses have been added. — RTM
Listed below are as many memory locations in the VIC as I could find by PEEKing around the memory. I also found out how to stop the use of the RUN/STOP key by the statement POKE788,194 and to restore the RUN/STOP key, POKE788, 191. This also stops the TI and TI$ when POKEing 788,194. I hope these are as useful to you as they were to me.
0–2 — USR function vectors. (Here is where the memory address is placed for jumping to a machine language routine from BASIC when you want to transfer a number from BASIC to the machine language routine.)
43–44 — Start of BASIC. (These two bytes contain the address where your BASIC program starts. PEEK (43) + PEEK (44) * 256 will give the address as a decimal number.)
45–46 — End of BASIC, start of variables. (Using the formula above, you can find out where your program ends in memory. The VIC starts storing its simple variables wherever there is room just above the program.)
47–48 — Array table. (The arrays are stored here.)
49–50 — End of Arrays.
51–52 — Start of Strings. (String variables.)
55–56 — End of memory. (How much RAM is available for use in BASIC. Sometimes, machine language programs are put at the "top of available RAM." 55 and 56 must be changed to fool the VIC into thinking that it has less memory for a BASIC program so it will not "write over" the machine language program. Changing the definition of end-of-memory will "protect" the machine language.)
57–58 — Current line number. (BASIC keeps track of the program line number.)
115–138 — Charget RAM code. (There is a small machine language program placed into this location each time power comes on. It gets a character in BASIC, but machine language programmers can put a JMP in it to allow the addition of new BASIC commands. Like the clock, the keyboard, and a few other items, this routine is constantly checked by BASIC to see if anything needs to be done. It can be used, therefore, as a way to append things to BASIC. You could not append to the keyboard checking routine, for example, because it is frozen into ROM. This part of BASIC'S house-keeping is in RAM.)
145 — Run/Stop keys pressed, left shift pressed, polls every other of the bottom row of keys. (You could PEEK this to see if these keys were being pressed).
160–162 — The clock. (Write: 10 PRINT PEEK (160); PEEK (161); PEEK (162) [cursor home] to see it running.)
197 — Last key pressed. (Write: 10 PRINT PEEK (197) to see what the VIC sees when you press keys.)
198 — Number of keys pressed (cumulative).
203 — Last key pressed.
204 — Tells if cursor is to blink (0) or not (1).
205 — Countdown for blinking of cursor.
246 — Tells if SHIFT, Commodore, or CTRL keys are pressed.
512–600 — BASIC buffer. (A "storage" buffer is a temporary holding area where bytes wait until there is time to use them. BASIC itself uses this area).
631–640 — Keyboard buffer.
651–652 — Repeat keys pressed.
788–789 — Interrupt address. (Important in machine language programming.)
4096 — BASIC starts. (Where the first byte of your BASIC program starts.)