Technical articleArtículo técnico

Registers and Data TypesRegistros y tipos de datos

How data registers, address registers, and byte, word, and long word values shape 68000 code.Cómo los registros de datos, registros de dirección y valores byte, word y long word dan forma al código 68000.

UpdatedActualizado

July 22, 202622 de julio de 2026

DifficultyDificultad

BeginnerInicial

Reading timeTiempo de lectura

8 min read8 min de lectura

D0-D7 data registers

D0 through D7 are the 68000's data registers. They are 32-bit registers used for arithmetic, comparisons, temporary values, counters, bit operations, and many small pieces of game state. In Mega Drive reverse engineering, D registers often carry coordinates, animation indices, counters, flags, or values loaded from tables.

A data register can be accessed as a byte, word, or long word. The size suffix on the instruction controls how much of the register is used. Byte and word operations on D registers affect the lower part of the register, while long-word operations use the full 32 bits.

A0-A7 address registers

A0 through A7 are address registers. They are intended for memory addresses rather than general arithmetic values. Code commonly loads an address into an A register, then reads or writes memory through it. That makes A registers especially important when following pointer tables, object structures, text, maps, and graphics resources.

RegisterRoleNotes
D0-D7General-purpose data registersCommonly used for arithmetic, counters, flags, and temporary values.
A0-A6Address registersUsually hold pointers to memory, tables, objects, strings, or buffers.
A7Stack PointerUsed by calls, returns, interrupts, and explicit stack operations.
PCProgram CounterPoints to the next instruction that will be fetched.
SRStatus RegisterStores processor state and condition flags used by branches.

A7 as Stack Pointer

A7 has a special role as the Stack Pointer. The stack is a memory area used for return addresses, temporary saved registers, interrupt state, and explicit push/pop-style work. A subroutine call places a return address on the stack, andrtstakes that address back to continue execution.

PC and SR

The Program Counter, or PC, points at the next instruction the CPU will fetch. Normal execution advances it automatically. Branches, jumps, subroutine calls, returns, traps, and interrupts change it more directly. When you trace code, the PC is the thread you follow.

The Status Register, or SR, stores processor state. The lower condition code bits are especially visible: zero, negative, carry, overflow, and extend. Arithmetic and comparison instructions update these flags, and conditional branches use them to decide whether to jump.

Byte, word, and long word

The three everyday data sizes are byte, word, and long word. A byte is 8 bits, a word is 16 bits, and a long word is 32 bits. The suffixes.b,.w, and.lmake the intended size visible in assembly.

SizeBitsCommon suffixTypical use
Byte8.bSmall counters, flags, packed fields
Word16.wCoordinates, tile IDs, many hardware values
Long word32.lPointers, larger arithmetic, full registers

Signed values and sign extension

A register only stores bits. Whether those bits are treated as signed or unsigned depends on the instruction and the programmer's intent. In two's complement form, the top bit of the chosen size acts as the sign bit: for a byte, bit 7; for a word, bit 15; for a long word, bit 31.

Sign extension copies that sign bit into the larger size. If a signed byte value like$ffrepresents -1, extending it to a word should produce$ffff, not$00ff.

68000 assembly
move.b  #$ff,d0
ext.w   d0
ext.l   d0

move.b, move.w, and move.l

68000 assembly
move.b  #$7f,d0
move.w  #$1234,d1
move.l  #$00123456,d2

move.b #$7f,d0writes the byte value$7finto the low byte of D0.

move.w #$1234,d1writes the word value$1234into the low word of D1.

move.l #$00123456,d2writes the full long-word value into D2, replacing all 32 bits.

Common size-mixing mistakes

  • Reading a byte from a table, then later comparing the whole long word without clearing or extending the register first.
  • Treating an address register like a byte-sized scratch register. Address registers are for addresses and do not support every data register operation.
  • Forgetting that Mega Drive ROM data is big-endian, so a word like$1234appears as12 34in the ROM.
  • Using a signed branch or comparison when the value should be treated as unsigned, or the reverse. The bits are the same; the chosen instruction changes the meaning.