
The Motorola 68K line of CPUs is probably among the most coder-friendly on the market, with its rich feature set and sensible syntax. This makes it an ideal choice for learning assembler coding, but be warned: once you understand the inner workings of the 68K, you might find yourself disliking the design of other CPUs. Switching from 68K to x86 coding is like trading your SUV for a kit car.

A CPU isn’t magical, though it might seem like you need to master some arcane art to program one. It’s simply a unit that can move data around, store it in internal registers, and perform calculations. Once you understand the basics, it’s actually pretty straightforward.
The 68000 CPU features eight data registers, eight address registers, a Program Counter, and a Status Register. The 68080 CPU, found in Apollo computers, adds 40 extra registers for calculations and data storage. In the remaining articles of this series, the focus will be on the classic 68K, used in early Amiga, Atari, and Apple computers, the Sega Megadrive, and various other devices like laser printers, synthesizers, and medical equipment.
d0-d7 : 32 bit data registers
a0-a7 : 32 bit Address registers
pc : 24 bit Program Counter
sr : 16 bit Status Register
Lower 8 bits are the Condition Control Register
Higher 8 bits are system control bits
Next up are the CPU’s instructions. These are stored in memory and executed by the CPU one by one sequentially. The PC register always holds the address of the next instruction to run. Changing the value of the PC register will make the CPU jump to that memory location to execute code.
Address Instruction
$f8000 moveq #10,d0
$f8002 moveq #5,d1 <- pc register = $f8004
$f8004 add.l d0,d1
These instructions happen to be two bytes each, but a 68K instruction can range from two to ten bytes in length.
In addition to showing how the CPU knows which instruction to execute next, the example also introduces two common commands: Move, for transferring data, and Add, for performing a mathematical addition. There are several variants of both these instructions, but explaining these details is beyond the scope of this article.

This is all well and good, but how does it turn into a real program a computer user can run? That’s where integration with the rest of the hardware comes in. The CPU, or Central Processing Unit, sits at the core of the hardware design, executing commands. By sending data to the screen buffer, it displays images on the screen, and by fetching data from I/O (input/output), it processes the user’s keyboard input.
For more information and a straightforward example, take a look at this article next.


