The C64 uses an 8-bit MOS Technology 6510 microprocessor. …
The C64 uses an 8-bit MOS Technology 6510 microprocessor.
https://twetch.app/t/eda79065558b503523358aa283a0f0cd6c6b30123e727052a8cbb95427842205
Replies
This is a close derivative of the 6502 with an added 6-bit internal I/O port that in the C64 is used for two purposes:
to bank-switch the machine's read-only memory (ROM) in and out of the processor's address space, and to operate the datasette tape recorder.
The C64 has 64½ KB of RAM, of which 1024×½ bytes are color RAM for text mode and 38 KB are available to built-in Commodore BASIC 2.0 on startup.
There is 20 KB of ROM, made up of the BASIC interpreter, the KERNAL, and the character ROM.
As the processor could only address 64 KB at a time, the ROM was mapped into memory, and only 38,911 bytes of RAM (plus 4 KB in between the ROMs) were available at startup.
Most "breadbox" Commodore 64s used 4164 DRAM, with eight chips to total up 64K of system RAM.
Late breadbox models and all C64Cs used 41464 DRAM (64K×4) chips which stored 32 KB per chip, so only two were required.
Since 4164 DRAMs are 64K×1, eight chips are needed to make an entire byte, and the computer will not function without all of them present.
Thus, the first chip contains Bit 0 for the entire memory space, the second chip contains Bit 1, and so forth.
This also makes detecting faulty RAM easy, as a bad chip will display random characters on the screen and the character displayed can be used to determine the faulty RAM.
The C64 performs a RAM test on power up and if a RAM error is detected, the amount of free BASIC memory will be lower than the normal 38911 figure.
If the faulty chip is in lower memory, then an ?OUT OF MEMORY IN 0 error is displayed rather than the usual BASIC startup banner. The color RAM at $D800 uses a separate 2114 SRAM chip and is gated directly to the VIC-II.
The C64 uses a somewhat complicated memory banking scheme; the normal power-on default is to have the BASIC ROM mapped in at $A000-$BFFF and the screen editor/KERNAL ROM at $E000-$FFF9.
RAM underneath the system ROMs can be written to, but not read back without swapping out the ROMs. $01 contains a register with control bits for enabling/disabling the system ROMS as well as the I/O area at $D000.
Most software swaps out BASIC, often also the KERNAL, in which case the user must provide his own code for I/O and interrupt handling.
If the KERNAL ROM is swapped out, BASIC will be removed with it, and it is not possible to have BASIC active without the KERNAL.
The character ROM is normally not visible to the CPU—it has two mirrors at $1000 and $9000, but only the VIC-II can see them and the CPU will see RAM in those locations.
The character ROM may be swapped into $D000-$DFFF where it is visible to the CPU. Since doing so necessitates swapping out the I/O registers, interrupts must be disabled first.
Graphics memory and data cannot be placed at $1000 or $9000 as the VIC-II will see the character ROM there instead.
By disabling I/O, $D000-$DFFF becomes free RAM. The color RAM at $D800 is swapped along with the I/O registers and this area can be used for static graphics data such as character sets since the VIC-II cannot see the I/O registers or color RAM.
If all ROMs and the I/O area are swapped out, the entire 64k RAM space is available aside from $0/$1 and the CPU vectors at $FFFA-$FFFF.
$C000-$CFFF is free RAM and normally not used by anything; because of this, it is an ideal location to store short machine language programs that can be accessed from BASIC.
The cassette buffer at $0334 can also be used to store short machine language routines provided that a Datasette is not used, which will overwrite the buffer.
C64 cartridges can map anywhere in the CPU's address space, although auto starting requires the presence of a special string at $8000 which contains "CBM" followed by the address where program execution begins,
so most cartridge software maps into $8000 to ensure continuity with the header string.
A few early C64 cartridges released in 1982 use Ultimax mode (or MAX mode), a leftover feature of the failed MAX Machine.
These cartridges map into $F000 and displace the KERNAL ROM. If Ultimax mode is used, the programmer will have to provide code for handling system interrupts.
The cartridge port has 14 address lines, so only 16 KB of ROM can be accessed.
Disk and tape software normally load at the start of BASIC memory ($0801) and use a small BASIC stub (e.g., 10 SYS(2064)) to jump to the start of the program.
Although no Commodore 8-bit machine except the C128 can automatically boot from a floppy disk, some software intentionally overwrites certain BASIC vectors in the process of loading so that execution begins automatically -
- rather than requiring the user to type RUN at the BASIC prompt following loading.
The KERNAL ROM checks on power up for the presence of an auto start string at $8000, and also when Run/Stop-Restore is pressed.
Some software places a dummy header into $8000 so the user can reset or restart the program by pressing Run/Stop-Restore.
Around 300 cartridges were released for the C64, mostly in the machine's first 2-1/2 years on the market, after which most software outgrew the 16 KB cartridge limit.
In the final years of the C64, larger software companies such as Ocean began releasing games on bank-switched cartridges.
Utility software such as a machine language monitor designed to be used from within BASIC loads at $8000 or $C000 and can generally be exited from and control returned to BASIC.
Software that loads at $0801 cannot normally be used in conjunction with another BASIC program.
Commodore did not include a reset button on any of their computers until the CBM-II line, but there were third-party cartridges with a reset button on them.
It is possible to trigger a soft reset by jumping to the CPU reset routine at $FCE2 (64738). A few programs use this as an "exit" feature, although it does not clear memory.
The KERNAL ROM went through three separate revisions, mostly designed to fix bugs. The initial version is only found on 326298 motherboards, used in the first production models, and cannot detect if an NTSC or PAL VIC-II is present.
The second revision is found on all C64s made from late 1982 through 1985. The third and last KERNAL ROM revision was introduced on the 250466 motherboard (late breadbin models with 41464 RAM) and is found in all C64Cs.
The 6510 CPU is clocked at 1.023 MHz (NTSC) and 0.985 MHz (PAL), lower than some competing systems (for example, the Atari 800 is clocked at 1.79 MHz).
A performance boost can be gained by disabling the VIC-II's video output via a register write; this feature is often used by tape and disk fastloaders as well as the KERNAL cassette routine.
The Restore key is gated directly to the CPU's NMI line and will generate an NMI if pressed. The KERNAL handler for the NMI checks if Run/Stop is also pressed, if not, it ignores the NMI and simply exits back out.
Run/Stop-Restore normally functions as a soft reset in BASIC that restores all I/O registers to their power on default state, but does not clear memory or reset pointers, so any BASIC programs in memory will be left untouched.
Machine language software usually disables Run/Stop-Restore by remapping the NMI vector to a dummy RTI instruction, as mentioned above it occasionally employs it as a restart feature by setting up a dummy cartridge header.
The NMI can be used for an extra interrupt thread by programs as well, but runs the risk of a system lockup or undesirable side effects if the Restore key is accidentally pressed, as this will trigger an inadvertent activation of the NMI thread.