GameBoy Assembly Language Primer


GameBoy Memory Map

The GameBoy has physical memory space from $0000 to $FFFF:

Memory ReadAddress SpaceMemory Write
Interrupt Enable RegisterFFFFInterrupt Enable Register
High RAMFFFEHigh RAM
FF80
I/O RegistersFF7FI/O Registers
FF00
.FEFF.
FEA0
Object Attribute MemoryFE9FObject Attribute Memory
FE00
.FDFF.
E000
Low RAMDFFFLow RAM
C000
Cart RAM (Optional)BFFFCart RAM (Optional)
A000
Video RAM9FFFVideo RAM
8000
ROM Bank 1-XXX7FFFRAM/ROM Select (MBC1 Only)
6000
5FFF RAM Bank Select
4000
ROM Bank 03FFFROM Bank Select MS Byte (MBC5 Only)
3000
2FFFROM Bank Select LS Byte
2000
1FFF RAM Bank Enable
0000

Video RAM Map

Here is the layout of the Video RAM:

Memory Read/WriteAddress Space
Tile Map 29FFF
9C00
Tile Map 19BFF
9800
Tiles $00-$7F (FF40:Bit4=0)97FF
9000
Tiles $80-$FF8FFF
8800
Tiles $00-$7F (FF40:Bit4=1)87FF
8000

ROM Bank 0 Read Map

The lower part of ROM bank 0 Read is setup like the following:

Memory ReadAddress Space
Cart Header Info Area014F
0100
Hi-to-Lo Interrupt Vector0060
Serial Transfer Complete Interrupt Vector0058
Timer Overflow Interrupt Vector0050
LCDC Interrupt Vector0048
Vertical Blank Interrupt Vector0040
Restart Vector $38 0038
Restart Vector $300030
Restart Vector $280028
Restart Vector $200020
Restart Vector $180018
Restart Vector $100010
Restart Vector $080008
Restart Vector $000000

Cart Header Info Area Map

Memory ReadAddress SpaceFormat
Checksum L014F
Checksum H014E
Complement Check014D
Mask ROM Version014C
Old Maker Code014B$33
Destination Code014A0 = Jap, 1 = non-Jap
Cart RAM Size0149
ROM Size0148
Cartridge Type0147
Game Unit Code0146$03=SGB Features
Maker Code L (ascii hex)0145
Maker Code H (ascii hex)0144
Color Compatibility0143$80=GBC Support
Game Title (uppercase ascii)0142
0134
Nintendo Graphic0133
0104
JP $XXXX0103
0101
NOP ($00)0100

RAM Size

00None
012K Bytes1 Bank
028K Bytes1 Bank
0332K Bytes4 Banks
05128K Bytes16 Banks

ROM Size

BitsBytes
00 256K32K
01 512K64K
02 1M128K
03 2M256K
04 4M512K
05 8M1M
06 16M2M
52 9M1.1M
53 10M1.2M
54 12M1.5M

Cartridge Type

00ROM Only
01ROM+MBC1
02ROM+MBC1+RAM
03ROM+MBC1+RAM+Batt
05ROM+MBC
06 ROM+MBC2+Batt
08ROM+RAM
09ROM+RAM+Batt
0BROM+MMM01
0CROM+MMM01+RAM
0DROM+MMM01+RAM+Batt
0FROM+MBC3+Timer+Batt
10ROM+MBC3+Timer+RAM+Batt
11ROM+MBC3
12 ROM+MBC3+RAM
13ROM+MBC3+RAM+Batt
19ROM+MBC5
1AROM+MBC5+RAM
1BROM+MBC5+RAM+Batt
1CROM+MBC5+Rumble
1DROM+MBC5+Rumble+RAM
1EROM+MBC5+Rumble+RAM+Batt
1FPocket Camera
FDBandai TAMA5
FEHudson HuC-3
FFHudson HuC-1