Overview Technical Data Memory Map I/O Map Hardware Programming LCD Video Controller Sound Controller Timers DMA Transfers Communication Ports Keypad Input Interrupt Control System Control Other Cartridges BIOS Functions Unpredictable Things External Connectors |
General ARM7TDMI Information CPU Overview CPU Register Set CPU Flags CPU Exceptions The ARM7TDMI Instruction Sets THUMB Instruction Set ARM Instruction Set Pseudo Instructions and Directives Further Information CPU Instruction Cycle Times CPU Data Sheet About GBATEK About this Document |
Technical Data |
ARM Mode ARM7TDMI 32bit RISC CPU, 16.78MHz, 32bit opcodes (GBA) THUMB Mode ARM7TDMI 32bit RISC CPU, 16.78MHz, 16bit opcodes (GBA) CGB Mode Z80/8080-style 8bit CPU, 4.2MHz or 8.4MHz (CGB compatibility) DMG Mode Z80/8080-style 8bit CPU, 4.2MHz (monochrome gameboy compatib.) |
BIOS ROM 16 KBytes Work RAM 288 KBytes (32K in-chip + 256K on-board) VRAM 96 KBytes OAM 1 KByte (128 OBJs 3x16bit, 32 OBJ-Rotation/Scalings 4x16bit) Palette RAM 1 KByte (256 BG colors, 256 OBJ colors) |
Display 240x160 pixels (2.9 inch TFT color LCD display) BG layers 4 background layers BG types Tile/map based, or Bitmap based BG colors 256 colors, or 16 colors/16 palettes, or 32768 colors OBJ colors 256 colors, or 16 colors/16 palettes Effects Rotation/Scaling, alpha blending, fade-in/out, mosaic, window OBJ size 12 types (in range 8x8 up to 64x64 dots) OBJs/Screen max. 128 OBJs of any size (up to 64x64 dots each) OBJs/Line max. 128 OBJs of 8x8 dots size (under best circumstances) Priorities OBJ/OBJ: 0-127, OBJ/BG: 0-3, BG/BG: 0-3 Effects Rotation/Scaling, alpha blending, fade-in/out, mosaic, window |
Analogue 4 channel CGB compatible Digital 2 DMA sound channels Output Built-in speaker, or stereo headphones |
Gamepad 4 Direction Keys, 6 Buttons |
Serial Port Various transfer modes, 4-Player Link, Single Game Pak play |
GBA Game Pak max. 32MB ROM or flash ROM + max 64K SRAM CGB Game Pak max. 32KB ROM + 8KB SRAM (more memory requires banking) |
Battery Life-time approx. 15 hours External 3.3V DC (works with somewhat 2.7V-3.3V, or maybe a bit more) |
Memory Map |
0000:0000-0000:3FFF BIOS - System ROM (16 KBytes) 0000:4000-01FF:FFFF Not used 0200:0000-0203:FFFF WRAM - On-board Work RAM (256 KBytes) 2 Wait 0204:0000-02FF:FFFF Not used 0300:0000-0300:7FFF WRAM - In-chip Work RAM (32 KBytes) 0300:8000-03FF:FFFF Not used 0400:0000-0400:03FE I/O Registers 0400:0400-04FF:FFFF Not used |
0500:0000-0500:03FF BG/OBJ Palette RAM (1 Kbyte) 0500:0400-05FF:FFFF Not used 0600:0000-0617:FFFF VRAM - Video RAM (96 KBytes) 0618:0000-06FF:FFFF Not used 0700:0000-0700:03FF OAM - OBJ Attributes (1 Kbyte) 0700:0400-07FF:FFFF Not used |
0800:0000-09FF:FFFF Game Pak ROM/FlashROM (max 32MB) - Wait State 0 0A00:0000-0BFF:FFFF Game Pak ROM/FlashROM (max 32MB) - Wait State 1 0C00:0000-0DFF:FFFF Game Pak ROM/FlashROM (max 32MB) - Wait State 2 0E00:0000-0E00:FFFF Game Pak SRAM (max 64 KBytes) - 8bit Bus width 0E01:0000-0FFF:FFFF Not used |
1000:0000-FFFF:FFFF Not used (upper 4bits of address bus unused) |
Region Bus Read Write Cycles BIOS ROM 32 8/16/32 - 1/1/1 Work RAM 32K 32 8/16/32 8/16/32 1/1/1 I/O 32 8/16/32 8/16/32 1/1/1 OAM 32 8/16/32 16/32 1/1/1 * Work RAM 256K 16 8/16/32 8/16/32 3/3/6 ** Palette RAM 16 8/16/32 16/32 1/1/2 * VRAM 16 8/16/32 16/32 1/1/2 * GamePak ROM 16 8/16/32 - 5/5/8 **/*** GamePak Flash 16 8/16/32 16/32 5/5/8 **/*** GamePak SRAM 8 8 8 5 ** |
* Plus 1 cycle if GBA accesses video memory at the same time. ** Default waitstate settings, see System Control chapter. *** Separate timings for sequential, and non-sequential accesses. One cycle equals approx. 59.59ns (ie. 16.78MHz clock). |
I/O Map |
000h R/W DISPCNT LCD Control 002h R/W - Undocumented - Green Swap 004h R/W DISPSTAT General LCD Status (STAT,LYC) 006h R VCOUNT Vertical Counter (LY) 008h R/W BG0CNT BG0 Control 00Ah R/W BG1CNT BG1 Control 00Ch R/W BG2CNT BG2 Control 00Eh R/W BG3CNT BG3 Control 010h W BG0HOFS BG0 X-Offset 012h W BG0VOFS BG0 Y-Offset 014h W BG1HOFS BG1 X-Offset 016h W BG1VOFS BG1 Y-Offset 018h W BG2HOFS BG2 X-Offset 01Ah W BG2VOFS BG2 Y-Offset 01Ch W BG3HOFS BG3 X-Offset 01Eh W BG3VOFS BG3 Y-Offset 020h W BG2PA BG2 Rotation/Scaling Parameter A (dx) 022h W BG2PB BG2 Rotation/Scaling Parameter B (dmx) 024h W BG2PC BG2 Rotation/Scaling Parameter C (dy) 026h W BG2PD BG2 Rotation/Scaling Parameter D (dmy) 028h-02Ah W BG2X BG2 Reference Point X-Coordinate 02Ch-02Eh W BG2Y BG2 Reference Point Y-Coordinate 030h W BG3PA BG3 Rotation/Scaling Parameter A (dx) 032h W BG3PB BG3 Rotation/Scaling Parameter B (dmx) 034h W BG3PC BG3 Rotation/Scaling Parameter C (dy) 036h W BG3PD BG3 Rotation/Scaling Parameter D (dmy) 038h-03Ah W BG3X BG3 Reference Point X-Coordinate 03Ch-03Eh W BG3Y BG3 Reference Point Y-Coordinate 040h W WIN0H Window 0 Horizontal Dimensions 042h W WIN1H Window 1 Horizontal Dimensions 044h W WIN0V Window 0 Vertical Dimensions 046h W WIN1V Window 1 Vertical Dimensions 048h R/W WININ Control Inside of Window(s) 04Ah R/W WINOUT Control Outside of Windows & Inside of OBJ Window 04Ch W MOSAIC Mosaic Size 04Eh - - Not used 050h R/W BLDCNT Color Special Effects Selection (formerly BLDMOD) 052h W BLDALPHA Alpha Blending Coefficients (formerly COLEV) 054h W BLDY Brightness (Fade-In/Out) Coefficient(formerly COLY) 056h-05Eh - - Not used |
060h R/W SOUND1CNT_L Channel 1 Sweep register (SG10_L)(NR10) 062h R/W SOUND1CNT_H Channel 1 Duty/Length/Envelope (SG10_H)(NR11, NR12) 064h R/W SOUND1CNT_X Channel 1 Frequency/Control (SG11) (NR13, NR14) 066h - - Not used - 068h R/W SOUND2CNT_L Channel 2 Duty/Length/Envelope (SG20) (NR21, NR22) 06Ah - - Not used - 06Ch R/W SOUND2CNT_H Channel 2 Frequency/Control (SG21) (NR23, NR24) 06Eh - - Not used - 070h R/W SOUND3CNT_L Channel 3 Stop/Wave RAM select (SG30_L)(NR30) 072h R/W SOUND3CNT_H Channel 3 Length/Volume (SG30_H)(NR31, NR32) 074h R/W SOUND3CNT_X Channel 3 Frequency/Control (SG31) (NR33, NR34) 076h - - Not used - 078h R/W SOUND4CNT_L Channel 4 Length/Envelope (SG40) (NR41, NR42) 07Ah - - Not used - 07Ch R/W SOUND4CNT_H Channel 4 Frequency/Control (SG41) (NR43, NR44) 07Eh - - Not used - 080h R/W SOUNDCNT_L Control Stereo/Volume/Enable (SGCNT0_L)(NR50, NR51) 082h R/W SOUNDCNT_H Control Mixing/DMA Control (SGCNT0_H) 084h R/W SOUNDCNT_X Control Sound on/off (SGCNT1) (NR52) 086h - - Not used 088h BIOS SOUNDBIAS Sound PWM Control (SG_BIAS) 08Ah-08Eh - - Not used 090h-09Eh R/W WAVE_RAM Channel 3 Wave Pattern RAM (2 banks!!) (SGWR) 0A0h-0A2h W FIFO_A Channel A FIFO, Data 0-3 (SGFIFOA) 0A4h-0A6h W FIFO_B Channel B FIFO, Data 0-3 (SGFIFOB) 0A8h-0AEh - - Not used |
0B0h-0B2h W DMA0SAD DMA 0 Source Address 0B4h-0B6h W DMA0DAD DMA 0 Destination Address 0B8h W DMA0CNT_L DMA 0 Word Count 0BAh R/W DMA0CNT_H DMA 0 Control 0BCh-0BEh W DMA1SAD DMA 1 Source Address 0C0h-0C2h W DMA1DAD DMA 1 Destination Address 0C4h W DMA1CNT_L DMA 1 Word Count 0C6h R/W DMA1CNT_H DMA 1 Control 0C8h-0CAh W DMA2SAD DMA 2 Source Address 0CCh-0CEh W DMA2DAD DMA 2 Destination Address 0D0h W DMA2CNT_L DMA 2 Word Count 0D2h R/W DMA2CNT_H DMA 2 Control 0D4h-0D6h W DMA3SAD DMA 3 Source Address 0D8h-0DAh W DMA3DAD DMA 3 Destination Address 0DCh W DMA3CNT_L DMA 3 Word Count 0DEh R/W DMA3CNT_H DMA 3 Control 0E0h-0FEh - - Not used |
100h R/W TM0CNT_L Timer 0 Counter/Reload (formerly TM0D) 102h R/W TM0CNT_H Timer 0 Control (formerly TM0CNT) 104h R/W TM1CNT_L Timer 1 Counter/Reload (formerly TM1D) 106h R/W TM1CNT_H Timer 1 Control (formerly TM1CNT) 108h R/W TM2CNT_L Timer 2 Counter/Reload (formerly TM2D) 10Ah R/W TM2CNT_H Timer 2 Control (formerly TM2CNT) 10Ch R/W TM3CNT_L Timer 3 Counter/Reload (formerly TM3D) 10Eh R/W TM3CNT_H Timer 3 Control (formerly TM3CNT) 110h-11Eh - - Not used |
120h-122h R/W SIODATA32 SIO Data (Normal-32bit Mode) (shared with below!) 120h R/W SIOMULTI0 SIO Data 0 (Parent) (Multi-Player Mode) (SCD0) 122h R/W SIOMULTI1 SIO Data 1 (1st Child) (Multi-Player Mode) (SCD1) 124h R/W SIOMULTI2 SIO Data 2 (2nd Child) (Multi-Player Mode) (SCD2) 126h R/W SIOMULTI3 SIO Data 3 (3rd Child) (Multi-Player Mode) (SCD3) 128h R/W SIOCNT SIO Control Register (SCCNT_L) 12Ah R/W SIOMLT_SEND SIO Data (Local of Multi-Player) (shared below) 12Ah R/W SIODATA8 SIO Data (Normal-8bit and UART Mode) (SCCNT_H) 12Ch-12Eh - - Not used |
130h R KEYINPUT Key Status (formerly P1) 132h R/W KEYCNT Key Interrupt Control (formerly P1CNT) |
134h R/W RCNT SIO Mode Select/General Purpose Data (formerly R) 136h - IR Ancient - Infrared Register (Prototypes only) 138h-13Eh - - Not used 140h R/W JOYCNT SIO JOY Bus Control (formerly HS_CTRL) 142h-14Eh - - Not used 150h-152h R/W JOY_RECV SIO JOY Bus Receive Data (formerly JOYRE) 154h-156h R/W JOY_TRANS SIO JOY Bus Transmit Data (formerly JOYTR) 158h R/? JOYSTAT SIO JOY Bus Receive Status (formerly JSTAT) 15Ah-1FEh - - Not used |
200h R/W IE Interrupt Enable Register 202h R/W IF Interrupt Request Flags / IRQ Acknowledge 204h R/W WAITCNT Game Pak Waitstate Control (formerly WSCNT) 206h - - Not used 208h R/W IME Interrupt Master Enable Register 20Ah-2FFh - - Not used 300h R/W HALTCNT Undocumented - Power Down Control 302h-40Fh - - Not used 410h ? ? Undocumented - Purpose Unknown ??? 0FFh 411h-7FFh - - Not used 800h-802h R/W ? Undocumented - Internal Memory Control (R/W) 804h-FFFFh - - Not used |
LCD Video Controller |
LCD I/O Display Control |
Bit Expl. 0-2 BG Mode (0-5=Video Mode 0-5, 6-7=Prohibited) 3 Reserved for BIOS (CGB Mode - cannot be changed after startup) 4 Display Frame Select (0-1=Frame 0-1) (for BG Modes 4,5 only) 5 H-Blank Interval Free (1=Allow access to OAM during H-Blank) 6 OBJ Character VRAM Mapping (0=Two dimensional, 1=One dimensional) 7 Forced Blank (1=Allow access to VRAM,Palette,OAM) 8 Screen Display BG0 (0=Off, 1=On) 9 Screen Display BG1 (0=Off, 1=On) 10 Screen Display BG2 (0=Off, 1=On) 11 Screen Display BG3 (0=Off, 1=On) 12 Screen Display OBJ (0=Off, 1=On) 13 Window 0 Display Flag (0=Off, 1=On) 14 Window 1 Display Flag (0=Off, 1=On) 15 OBJ Window Display Flag (0=Off, 1=On) |
Mode Rot/Scal Layers Size Tiles Colors Features 0 No 0123 256x256..512x515 1024 16/16..256/1 SFMABP 1 Mixed 012- (BG0,BG1 as above Mode 0, BG2 as below Mode 2) 2 Yes --23 128x128..1024x1024 256 256/1 S-MABP 3 Yes --?- 240x160 1 32768 --MABP 4 Yes --?? 240x160 2 256/1 --MABP 5 Yes --?? 160x128 2 32768 --MABP |
Bit Expl. 0 Green Swap (0=Normal, 1=Swap) 1-15 Not used |
LCD I/O Interrupts and Status |
Bit Expl. 0 V-Blank flag (Read only) (1=VBlank) 1 H-Blank flag (Read only) (1=HBlank) 2 V-Counter flag (Read only) (1=Match) 3 V-Blank IRQ Enable (1=Enable) 4 H-Blank IRQ Enable (1=Enable) 5 V-Counter IRQ Enable (1=Enable) 6-7 Not used 8-15 V-Count Setting (0-227) |
Bit Expl. 0-7 Current scanline (0-227) 8-15 Not Used |
LCD I/O BG Control |
Bit Expl. 0-1 BG Priority (0-3, 0=Highest) 2-3 Character Base Block (0-3, in units of 16 KBytes) (=BG Tile Data) 4-5 Not used (must be zero) 6 Mosaic (0=Disable, 1=Enable) 7 Colors/Palettes (0=16/16, 1=256/1) 8-12 Screen Base Block (0-31, in units of 2 KBytes) (=BG Map Data) 13 Display Area Overflow (0=Transparent, 1=Wraparound; BG2CNT/BG3CNT only) 14-15 Screen Size (0-3) |
Value Text Mode Rotation/Scaling Mode 0 256x256 (2K) 128x128 (256 bytes) 1 512x256 (4K) 256x256 (1K) 2 256x512 (4K) 512x512 (4K) 3 512x512 (8K) 1024x1024 (16K) |
LCD I/O BG Scrolling |
Bit Expl. 0-8 Offset (0-511) 9-15 Not used |
LCD I/O BG Rotation/Scaling |
Bit Expl. 0-7 Fractional portion (8 bits) 8-26 Integer portion (19 bits) 27 Sign (1 bit) 28-31 Not used |
Bit Expl. 0-7 Fractional portion (8 bits) 8-14 Integer portion (7 bits) 15 Sign (1 bit) |
Rotation Center X and Y Coordinates (x0,y0) Rotation Angle (alpha) Magnification X and Y Values (xMag,yMag) |
A = Cos (alpha) / xMag ;distance moved in direction x, same line B = Sin (alpha) / xMag ;distance moved in direction x, next line C = Sin (alpha) / yMag ;distance moved in direction y, same line D = Cos (alpha) / yMag ;distance moved in direction y, next line |
x0,y0 Rotation Center x1,y1 Old Position of a pixel (before rotation/scaling) x2,y2 New position of above pixel (after rotation scaling) A,B,C,D BG2PA-BG2PD Parameters (as calculated above) |
x2 = A(x1-x0) + B(y1-y0) + x0 y2 = C(x1-x0) + D(y1-y0) + y0 |
LCD I/O Window Feature |
Bit Expl. 0-7 X2, Rightmost coordinate of window, plus 1 8-15 X1, Leftmost coordinate of window |
Bit Expl. 0-7 Y2, Bottom-most coordinate of window, plus 1 8-15 Y1, Top-most coordinate of window |
Bit Expl. 0-3 Window 0 BG0-BG3 Enable Bits (0=No Display, 1=Display) 4 Window 0 OBJ Enable Bit (0=No Display, 1=Display) 5 Window 0 Color Special Effect (0=Disable, 1=Enable) 6-7 Not used 8-11 Window 1 BG0-BG3 Enable Bits (0=No Display, 1=Display) 12 Window 1 OBJ Enable Bit (0=No Display, 1=Display) 13 Window 1 Color Special Effect (0=Disable, 1=Enable) 14-15 Not used |
Bit Expl. 0-3 Outside BG0-BG3 Enable Bits (0=No Display, 1=Display) 4 Outside OBJ Enable Bit (0=No Display, 1=Display) 5 Outside Color Special Effect (0=Disable, 1=Enable) 6-7 Not used 8-11 OBJ Window BG0-BG3 Enable Bits (0=No Display, 1=Display) 12 OBJ Window OBJ Enable Bit (0=No Display, 1=Display) 13 OBJ Window Color Special Effect (0=Disable, 1=Enable) 14-15 Not used |
LCD I/O Mosaic Function |
Bit Expl. 0-3 BG Mosaic H-Size (minus 1) 4-7 BG Mosaic V-Size (minus 1) 8-11 OBJ Mosaic H-Size (minus 1) 12-15 OBJ Mosaic V-Size (minus 1) |
LCD I/O Color Special Effects |
Bit Expl. 0 BG0 1st Target Pixel (Background 0) 1 BG1 1st Target Pixel (Background 1) 2 BG2 1st Target Pixel (Background 2) 3 BG3 1st Target Pixel (Background 3) 4 OBJ 1st Target Pixel (Top-most OBJ pixel) 5 BD 1st Target Pixel (Backdrop) 6-7 Color Special Effect (0-3, see below) 0 = None (Special effects disabled) 1 = Alpha Blending (1st+2nd Target mixed) 2 = Brightness Increase (1st Target becomes whiter) 3 = Brightness Decrease (1st Target becomes blacker) 8 BG0 2nd Target Pixel (Background 0) 9 BG1 2nd Target Pixel (Background 1) 10 BG2 2nd Target Pixel (Background 2) 11 BG3 2nd Target Pixel (Background 3) 12 OBJ 2nd Target Pixel (Top-most OBJ pixel) 13 BD 2nd Target Pixel (Backdrop) 14-15 Not used |
Bit Expl. 0-4 EVA Coefficient (1st Target) (0..16 = 0/16..16/16, 17..31=16/16) 5-7 Not used 8-12 EVB Coefficient (2nd Target) (0..16 = 0/16..16/16, 17..31=16/16) 13-15 Not used |
I = MIN ( 31, I1st*EVA + I2nd*EVB ) |
Bit Expl. 0-4 EVY Coefficient (Brightness) (0..16 = 0/16..16/16, 17..31=16/16) 5-15 Not used |
I = I1st + (31-I1st)*EVY ;For Brightness Increase I = I1st - (I1st)*EVY ;For Brightness Decrease |
LCD VRAM Overview |
06000000-0600FFFF 64 KBytes shared for BG Map and Tiles 06010000-06017FFF 32 KBytes OBJ Tiles |
06000000-06013FFF 80 KBytes Frame 0 buffer (only 75K actually used) 06014000-06017FFF 16 KBytes OBJ Tiles |
06000000-06009FFF 40 KBytes Frame 0 buffer (only 37.5K used in Mode 4) 0600A000-06013FFF 40 KBytes Frame 1 buffer (only 37.5K used in Mode 4) 06014000-06017FFF 16 KBytes OBJ Tiles |
LCD VRAM Character Data |
LCD VRAM BG Screen Data Format (BG Map) |
Bit Expl. 0-9 Tile Number (0-1023) (a bit less in 256 color mode, because there'd be otherwise no room for the bg map) 10 Horizontal Flip (0=Normal, 1=Mirrored) 11 Vertical Flip (0=Normal, 1=Mirrored) 12-15 Palette Number (0-15) (Not used in 256 color/1 palette mode) |
Bit Expl. 0-7 Tile Number (0-255) |
LCD VRAM Bitmap BG Modes |
Bit Expl. 0-4 Red Intensity (0-31) 5-9 Green Intensity (0-31) 10-14 Blue Intensity (0-31) 15 Not used |
LCD OBJ - Overview |
1210 (=304*4-6) If "H-Blank Interval Free" bit in DISPCNT register is 0 954 (=240*4-6) If "H-Blank Interval Free" bit in DISPCNT register is 1 |
Cycles per Screen Pixels OBJ Type OBJ Type Screen Pixel Range 8 cycles per 8 pixels Normal OBJs 8..64 pixels 26 cycles per 8 pixels Rotation/Scaling OBJs 8..64 pixels (area clipped) 26 cycles per 8 pixels Rotation/Scaling OBJs 16..128 pixels (double size) |
LCD OBJ - OAM Attributes |
Bit Expl. 0-7 Y-Coordinate (0-255) 8 Rotation/Scaling Flag (0=Off, 1=On) When Rotation/Scaling used (Attribute 0, bit 8 set): 9 Double-Size Flag (0=Normal, 1=Double) When Rotation/Scaling not used (Attribute 0, bit 8 cleared): 9 OBJ Disable (0=Normal, 1=Not displayed) 10-11 OBJ Mode (0=Normal, 1=Semi-Transparent, 2=OBJ Window, 3=Prohibited) 12 OBJ Mosaic (0=Off, 1=On) 13 Colors/Palettes (0=16/16, 1=256/1) 14-15 OBJ Shape (0=Square,1=Horizontal,2=Vertical,3=Prohibited) |
Bit Expl. 0-8 X-Coordinate (0-511) When Rotation/Scaling used (Attribute 0, bit 8 set): 9-13 Rotation/Scaling Parameter Selection (0-31) (Selects one of the 32 Rotation/Scaling Parameters that can be defined in OAM, for details read next chapter.) When Rotation/Scaling not used (Attribute 0, bit 8 cleared): 9-11 Not used 12 Horizontal Flip (0=Normal, 1=Mirrored) 13 Vertical Flip (0=Normal, 1=Mirrored) 14-15 OBJ Size (0..3, depends on OBJ Shape, see Attr 0) Size Square Horizontal Vertical 0 8x8 16x8 8x16 1 16x16 32x8 8x32 2 32x32 32x16 16x32 3 64x64 64x32 32x64 |
Bit Expl. 0-9 Character Name (0-1023=Tile Number) 10-11 Priority relative to BG (0-3; 0=Highest) 12-15 Palette Number (0-15) (Not used in 256 color/1 palette mode) |
OBJ No. 0 with Priority relative to BG=1 ;hi OBJ prio, lo BG prio OBJ No. 1 with Priority relative to BG=0 ;lo OBJ prio, hi BG prio |
LCD OBJ - OAM Rotation/Scaling Parameters |
1st Group - PA=0700:0006, PB=0700:000E, PC=0700:0016, PD=0700:001E 2nd Group - PA=0700:0026, PB=0700:002E, PC=0700:0036, PD=0700:003E etc. |
LCD OBJ - VRAM Character (Tile) Mapping |
LCD Color Palettes |
05000000-050001FF - BG Palette RAM (512 bytes, 256 colors) 05000200-050003FF - OBJ Palette RAM (512 bytes, 256 colors) |
Bit Expl. 0-4 Red Intensity (0-31) 5-9 Green Intensity (0-31) 10-14 Blue Intensity (0-31) 15 Not used |
LCD Dimensions and Timings |
Visible 240 dots, 57.221 us, 960 cycles - 78% of h-time H-Blanking 68 dots, 16.212 us, 272 cycles - 22% of h-time Total 308 dots, 73.433 us, 1232 cycles - ca. 13.620 kHz |
Visible (*) 160 lines, 11.749 ms, 197120 cycles - 70% of v-time V-Blanking 68 lines, 4.994 ms, 83776 cycles - 30% of v-time Total 228 lines, 16.743 ms, 280896 cycles - ca. 59.737 Hz |
Sound Controller |
Sound Channel 1 - Tone & Sweep |
Bit Expl. 0-2 R/W Number of sweep shift (n=0-7) 3 R/W Sweep Frequency Direction (0=Increase, 1=Decrease) 4-6 R/W Sweep Time; units of 7.8ms (0-7, min=7.8ms, max=54.7ms) 7-15 - Not used |
X(t) = X(t-1) +/- X(t-1)/2^n |
Bit Expl. 0-5 W Sound length; units of (64-n)/256s (0-63) 6-7 R/W Wave Pattern Duty (0-3, see below) 8-10 R/W Envelope Step-Time; units of n/64s (1-7, 0=No Envelope) 11 R/W Envelope Direction (0=Decrease, 1=Increase) 12-15 R/W Initial Volume of envelope (1-15, 0=No Sound) |
0: 12.5% ( -_______-_______-_______ ) 1: 25% ( --______--______--______ ) 2: 50% ( ----____----____----____ ) (normal) 3: 75% ( ------__------__------__ ) |
Bit Expl. 0-10 W Frequency; 131072/(2048-n)Hz (0-2047) 11-13 - Not used 14 R/W Length Flag (1=Stop output when length in NR11 expires) 15 W Initial (1=Restart Sound) |
Sound Channel 2 - Tone |
Sound Channel 3 - Wave Output |
Bit Expl. 0-4 - Not used 5 R/W Wave RAM Bank Number (0-1, see below) 6 R/W Wave RAM Dimension (0=One bank/32 digits, 1=Two banks/64 digits) 7 R/W Sound Channel 3 Off (0=Stop, 1=Playback) 8-15 - Not used |
Bit Expl. 0-7 W Sound length; units of (256-n)/256s (0-255) 8-12 - Not used. 13-14 R/W Sound Volume (0=Mute/Zero, 1=100%, 2=50%, 3=25%) 15 R/W Force Volume (0=Use above, 1=Force 75% regardless of above) |
Bit Expl. 0-10 W Frequency; 131072/(2048-n) Hz (0-2047) 11-13 - Not used 14 R/W Length Flag (1=Stop output when length in NR31 expires) 15 W Initial (1=Restart Sound) |
Sound Channel 4 - Noise |
Bit Expl. 0-5 W Sound length; units of (64-n)/256s (0-63) 6-7 - Not used 8-10 R/W Envelope Step-Time; units of n/64s (1-7, 0=No Envelope) 11 R/W Envelope Direction (0=Decrease, 1=Increase) 12-15 R/W Initial Volume of envelope (1-15, 0=No Sound) |
Bit Expl. 0-2 R/W Dividing Ratio of Frequencies (r) 3 R/W Counter Step/Width (0=15 bits, 1=7 bits) 4-7 R/W Shift Clock Frequency (s) 8-13 - Not used 14 R/W Length Flag (1=Stop output when length in NR41 expires) 15 W Initial (1=Restart Sound) |
Sound Channel A and B - DMA Sound |
If Timer overflows then Move 8bit data from FIFO to sound circuit. If FIFO contains only 4 x 32bits (16 bytes) then Request more data per DMA Receive 4 x 32bit (16 bytes) per DMA Endif Endif |
Sound Control Registers |
Bit Expl. 0-2 Sound 1-4 Master volume RIGHT (0-7) 3 Not used 4-6 Sound 1-4 Master Volume LEFT (0-7) 7 Not used 8-11 Sound 1-4 Enable Flags RIGHT (each Bit 8-11, 0=Disable, 1=Enable) 12-15 Sound 1-4 Enable Flags LEFT (each Bit 12-15, 0=Disable, 1=Enable) |
Bit Expl. 0-1 Sound # 1-4 Volume (0=25%, 1=50%, 2=100%, 3=Prohibited) 2 DMA Sound A Volume (0=50%, 1=100%) 3 DMA Sound B Volume (0=50%, 1=100%) 4-7 Not used 8 DMA Sound A Enable RIGHT (0=Disable, 1=Enable) 9 DMA Sound A Enable LEFT (0=Disable, 1=Enable) 10 DMA Sound A Timer Select (0=Timer 0, 1=Timer 1) 11 DMA Sound A Reset FIFO (1=Reset) 12 DMA Sound B Enable RIGHT (0=Disable, 1=Enable) 13 DMA Sound B Enable LEFT (0=Disable, 1=Enable) 14 DMA Sound B Timer Select (0=Timer 0, 1=Timer 1) 15 DMA Sound B Reset FIFO (1=Reset) |
Bit Expl. 0 Sound 1 ON flag (Read Only) 1 Sound 2 ON flag (Read Only) 2 Sound 3 ON flag (Read Only) 3 Sound 4 ON flag (Read Only) 4-6 Not used 7 All sound on/off (0: stop all sound circuits) (Read/Write) 8-15 Not used |
Bit Expl. 0-9 Bias Level (Default=200h, converting signed samples into unsigned) 10-13 Not used 14-15 Amplitude Resolution/Sampling Cycle (Default=0, see below) |
0 9bit / 32.768kHz (Default, best for DMA channels A,B) 1 8bit / 65.536kHz 2 7bit / 131.072kHz 3 6bit / 262.144kHz (Best for FM channels 1-4) |
Comparision of CGB and GBA Sound |
Timers |
Bit Expl. 0-1 Prescaler Selection (0=F/1, 1=F/64, 2=F/256, 3=F/1024) 2 Count-up Timing (0=Normal, 1=See below) 3-5 Not used 6 Timer IRQ Enable (0=Disable, 1=IRQ on Timer overflow) 7 Timer Start/Stop (0=Stop, 1=Operate) 8-15 Not used |
DMA Transfers |
Bit Expl. 0-4 Not used 5-6 Dest Addr Control (0=Increment,1=Decrement,2=Fixed,3=Increment/Reload) 7-8 Source Adr Control (0=Increment,1=Decrement,2=Fixed,3=Prohibited) 9 DMA Repeat (0=Off, 1=On) (Must be zero if Bit 11 set) 10 DMA Transfer Type (0=16bit, 1=32bit) 11 Game Pak DRQ - DMA3 only - (0=Normal, 1=DRQ <from> Game Pak, DMA3) 12-13 DMA Start Timing (0=Immediately, 1=VBlank, 2=HBlank, 3=Special) The 'Special' setting (Start Timing=3) depends on the DMA channel: DMA0=Prohibited, DMA1/DMA2=Sound FIFO, DMA3=Video Capture 14 IRQ upon end of Word Count (0=Disable, 1=Enable) 15 DMA Enable (0=Off, 1=On) |
Communication Ports |
SIO Normal Mode |
Bit Expl. 0-14 Not used 15 Must be zero (0) for Normal/Multiplayer/UART modes |
Bit Expl. 0 Shift Clock (SC) (0=External, 1=Internal) 1 Internal Shift Clock (0=256KHz, 1=2MHz) 2 SI State (opponents SO) (0=Low, 1=High/None) --- (Read Only) 3 SO during inactivity (0=Low, 1=High) 4-6 Not used 7 Start Bit (0=Inactive/Ready, 1=Start/Active) 8-11 Not used 12 Transfer Length (0=8bit, 1=32bit) 13 Must be "0" for Normal Mode 14 IRQ Enable (0=Disable, 1=Want IRQ upon completion) 15 Not used |
Step Sender 1st Recepient 2nd Recipient Transfer 1: DATA #0 --> UNDEF --> UNDEF --> Transfer 2: DATA #1 --> DATA #0 --> UNDEF --> Transfer 3: DATA #2 --> DATA #1 --> DATA #0 --> Transfer 4: DATA #3 --> DATA #2 --> DATA #1 --> |
SIO Multi-Player Mode |
Bit Expl. 0-14 Not used 15 Must be zero (0) for Normal/Multiplayer/UART modes |
Bit Expl. 0-1 Baud Rate (0-3: 9600,38400,57600,115200 bps) 2 SI-Terminal (0=Parent, 1=Child) (Read Only) 3 SD-Terminal (0=Bad connection, 1=All GBAs Ready) (Read Only) 4-5 Multi-Player ID (0=Parent, 1-3=1st-3rd child) (Read Only?) 6 Multi-Player Error (0=Normal, 1=Error) (Read Only?) 7 Start/Busy Bit (0=Inactive, 1=Start/Busy) (Read Only for Slaves) 8-11 Not used 12 Must be "0" for Multi-Player mode 13 Must be "1" for Multi-Player mode 14 IRQ Enable (0=Disable, 1=Want IRQ upon completion) 15 Not used |
GBAs Bits Delays Timeout 1 18 None Yes 2 36 1 Yes 3 54 2 Yes 4 72 3 None |
SIO UART Mode |
Bit Expl. 0-14 Not used 15 Must be zero (0) for Normal/Multiplayer/UART modes |
Bit Expl. 0-1 Baud Rate (0-3: 9600,38400,57600,115200 bps) 2 CTS Flag (0=Send always/blindly, 1=Send only when SC=LOW) 3 Parity Control (0=Even, 1=Odd) 4 Send Data Flag (0=Not Full, 1=Full) (Read Only) 5 Receive Data Flag (0=Not Empty, 1=Empty) (Read Only) 6 Error Flag (0=No Error, 1=Error) (Read Only) 7 Data Length (0=7bits, 1=8bits) 8 FIFO Enable Flag (0=Disable, 1=Enable) 9 Parity Enable Flag (0=Disable, 1=Enable) 10 Send Enable Flag (0=Disable, 1=Enable) 11 Receive Enable Flag (0=Disable, 1=Enable) 12 Must be "1" for UART mode 13 Must be "1" for UART mode 14 IRQ Enable (0=Disable, 1=IRQ when any Bit 4/5/6 become set) 15 Not used |
SIO JOY BUS Mode |
Bit Expl. 0-14 Not used 14 Must be "1" for JOY BUS Mode 15 Must be "1" for JOY BUS Mode |
Bit Expl. 0 Device Reset Flag (Command FFh) (Read/Acknowledge) 1 Receive Complete Flag (Command 14h or 15h?) (Read/Acknowledge) 2 Send Complete Flag (Command 15h or 14h?) (Read/Acknowledge) 3-5 Not used 6 IRQ when receiving a Device Reset Command (0=Disable, 1=Enable) 7-15 Not used |
Bit Expl. 0 Not used 1 Receive Status Flag (0=Remote GBA is/was receiving) (Read Only?) 2 Not used 3 Send Status Flag (1=Remote GBA is/was sending) (Read Only?) 4-5 General Purpose Flag (Not assigned, may be used for whatever purpose) 6-15 Not used |
Receive FFh (Command) Send 00h (GBA Type number LSB (or MSB?)) Send 04h (GBA Type number MSB (or LSB?)) Send XXh (lower 8bits of SIOSTAT register) |
Receive 00h (Command) Send 00h (GBA Type number LSB (or MSB?)) Send 04h (GBA Type number MSB (or LSB?)) Send XXh (lower 8bits of SIOSTAT register) |
Receive 15h (Command) Receive XXh (Lower 8bits of JOY_RECV_L) Receive XXh (Upper 8bits of JOY_RECV_L) Receive XXh (Lower 8bits of JOY_RECV_H) Receive XXh (Upper 8bits of JOY_RECV_H) Send XXh (lower 8bits of SIOSTAT register) |
Receive 14h (Command) Send XXh (Lower 8bits of JOY_TRANS_L) Send XXh (Upper 8bits of JOY_TRANS_L) Send XXh (Lower 8bits of JOY_TRANS_H) Send XXh (Upper 8bits of JOY_TRANS_H) Send XXh (lower 8bits of SIOSTAT register) |
SIO General-Purpose Mode |
Bit Expl. 0 SC Data Bit (0=Low, 1=High) 1 SD Data Bit (0=Low, 1=High) 2 SI Data Bit (0=Low, 1=High) 3 SO Data Bit (0=Low, 1=High) 4 SC Direction (0=Input, 1=Output) 5 SD Direction (0=Input, 1=Output) 6 SI Direction (0=Input, 1=Output, but see below) 7 SO Direction (0=Input, 1=Output) 8 Interrupt Request (0=Disable, 1=Enable) 9-13 Not used 14 Must be "0" for General-Purpose Mode 15 Must be "1" for General-Purpose or JOYBUS Mode |
Infrared Communication |
Bit Expl. 0 Transmission Data (0=LED Off, 1=LED On) 1 READ Enable (0=Disable, 1=Enable) 2 Reception Data (0=None, 1=Signal received) (Read only) 3 AMP Operation (0=Off, 1=On) 4 IRQ Enable Flag (0=Disable, 1=Enable) 5-15 Not used |
Keypad Input |
Bit Expl. 0 Button A (0=Pressed, 1=Released) 1 Button B (etc.) 2 Select (etc.) 3 Start (etc.) 4 Right (etc.) 5 Left (etc.) 6 Up (etc.) 7 Down (etc.) 8 Button R (etc.) 9 Button L (etc.) 10-15 Not used |
Bit Expl. 0 Button A (0=Ignore, 1=Select) 1 Button B (etc.) 2 Select (etc.) 3 Start (etc.) 4 Right (etc.) 5 Left (etc.) 6 Up (etc.) 7 Down (etc.) 8 Button R (etc.) 9 Button L (etc.) 10-13 Not used 14 IRQ Enable Flag (0=Disable, 1=Enable) 15 IRQ Condition (0=Logical OR, 1=Logical AND) |
Interrupt Control |
Bit Expl. 0 Disable all interrupts (0=Disable All, 1=See IE register) 1-15 Not used |
Bit Expl. 0 LCD V-Blank (0=Disable) 1 LCD H-Blank (etc.) 2 LCD V-Counter Match (etc.) 3 Timer 0 Overflow (etc.) 4 Timer 1 Overflow (etc.) 5 Timer 2 Overflow (etc.) 6 Timer 3 Overflow (etc.) 7 Serial Communication (etc.) 8 DMA 0 (etc.) 9 DMA 1 (etc.) 10 DMA 2 (etc.) 11 DMA 3 (etc.) 12 Keypad (etc.) 13 Game Pak (external IRQ source) (etc.) 14-15 Not used |
Bit Expl. 0 LCD V-Blank (1=Request Interrupt) 1 LCD H-Blank (etc.) 2 LCD V-Counter Match (etc.) 3 Timer 0 Overflow (etc.) 4 Timer 1 Overflow (etc.) 5 Timer 2 Overflow (etc.) 6 Timer 3 Overflow (etc.) 7 Serial Communication (etc.) 8 DMA 0 (etc.) 9 DMA 1 (etc.) 10 DMA 2 (etc.) 11 DMA 3 (etc.) 12 Keypad (etc.) 13 Game Pak (external IRQ source) (etc.) 14-15 Not used |
00000018 b 128h ;IRQ vector: jump to actual BIOS handler 00000128 stmfd r13!,r0-r3,r12,r14 ;save registers to SP_irq 0000012C mov r0,4000000h ;ptr+4 to 03FFFFFC (mirror of 03007FFC) 00000130 add r14,r15,0h ;retadr for USER handler $+8=138h 00000134 ldr r15,[r0,-4h] ;jump to [03FFFFFC] USER handler 00000138 ldmfd r13!,r0-r3,r12,r14 ;restore registers from SP_irq 0000013C subs r15,r14,4h ;return from IRQ (PC=LR-4, CPSR=SPSR) |
Addr. Size Expl. 7FFCh 4 Pointer to user IRQ handler (32bit ARM code) 7FF8h 4 Interrupt Check Flag (for IntrWait/VBlankIntrWait functions) 7FF4h 4 Allocated Area 7FF0h 4 Pointer to Sound Buffer 7FE0h 16 Allocated Area 7FA0h 64 Default area for SP_svc Supervisor Stack (4 words/time) 7F00h 160 Default area for SP_irq Interrupt Stack (6 words/time) |
SP_svc=03007FE0h SP_irq=03007FA0h SP_usr=03007F00h |
System Control |
Bit Expl. 0-1 SRAM Wait Control (0..3 = 4,3,2,8 cycles) 2-3 Wait State 0 First Access (0..3 = 4,3,2,8 cycles) 4 Wait State 0 Second Access (0..1 = 2,1 cycles) 5-6 Wait State 1 First Access (0..3 = 4,3,2,8 cycles) 7 Wait State 1 Second Access (0..1 = 4,1 cycles; unlike above WS0) 8-9 Wait State 2 First Access (0..3 = 4,3,2,8 cycles) 10 Wait State 2 Second Access (0..1 = 8,1 cycles; unlike above WS0,WS1) 11-12 PHI Terminal Output (0..3 = Disable, 4.19MHz, 8.38MHz, 16.76MHz) 13 Not used 14 Game Pak Prefetch Buffer (Pipe) (0=Disable, 1=Enable) 15 Game Pak Type Flag (Read Only) (0=GBA, 1=CGB) |
Bit Expl. 0 Undocumented. First Boot Flag (0=First, 1=Further) 1-7 Undocumented. Not used. |
Bit Expl. 0-6 Undocumented. Not used. 7 Undocumented. Power Down Mode (0=Halt, 1=Stop) |
Bit Expl. 0 Purpose Unknown (Seems to lock up the GBA when set to 1) 1-3 Purpose Unknown (Read/Write able) 4 Purpose Unknown (Always zero - not used or write only) 5 Purpose Unknown (Seems to lock up the GBA when set to 0) 6-23 Purpose Unknown (Always zero - not used or write only) 24-27 Wait Control WRAM 256K (0-14 = 15..1 Waitstates, 15=Lockup) 28-31 Purpose Unknown (Read/Write able) |
Cartridges |
Cartridge Header |
Address Bytes Expl. 000h 4 ROM Entry Point (32bit ARM branch opcode, eg. "B rom_start") 004h 156 Nintendo Logo (compressed bitmap, required!) 0A0h 12 Game Title (uppercase ascii, max 12 characters) 0ACh 4 Game Code (uppercase ascii, 4 characters) 0B0h 2 Maker Code (uppercase ascii, 2 characters) 0B2h 1 Fixed value (must be 96h, required!) 0B3h 1 Main unit code (00h for current GBA models) 0B4h 1 Device type (huh ???) 0B5h 7 Reserved Area (should be zero filled) 0BCh 1 Software version (usually 00h) 0BDh 1 Complement check (header checksum, required!) 0BEh 2 Reserved Area (should be zero filled) --- Additional Multiboot Header Entries --- 0C0h 4 RAM Entry Point (32bit ARM branch opcode, eg. "B ram_start") 0C4h 1 Boot mode (init as 00h - BIOS overwrites this value!) 0C5h 1 Slace ID Number (init as 00h - BIOS overwrites this value!) 0C6h 26 Not used (seems to be unused) 0E4h 4 JOYBUS Entry Pt. (32bit ARM branch opcode, eg. "B joy_start") |
Value Expl. 01h Joybus mode 02h Normal mode 03h Multiplay mode |
Value Expl. 01h Slave #1 02h Slave #2 03h Slave #3 |
Cartridge ROM |
Backup SRAM |
Backup EEPROM |
2 bits "11" (Read Request) n bits eeprom address (MSB first, 6 or 14 bits, depending on EEPROM) 1 bit "0" |
4 bits - ignore these 64 bits - data (conventionally MSB first) |
2 bits "10" (Write Request) n bits eeprom address (MSB first, 6 or 14 bits, depending on EEPROM) 64 bits data (conventionally MSB first) 1 bit "0" |
Backup Flash ROM |
Backup DACS |
BIOS Functions |
BIOS Function Summary |
SWI Hex Function 0 00h SoftReset 1 01h RegisterRamReset 2 02h Halt 3 03h Stop 4 04h IntrWait 5 05h VBlankIntrWait 6 06h Div 7 07h DivArm 8 08h Sqrt 9 09h ArcTan 10 0Ah ArcTan2 11 0Bh CpuSet 12 0Ch CpuFastSet 13 0Dh -Undoc- ("GetBiosChecksum") 14 0Eh BgAffineSet 15 0Fh ObjAffineSet 16 10h BitUnPack 17 11h LZ77UnCompWram 18 12h LZ77UnCompVram 19 13h HuffUnComp 20 14h RLUnCompWram 21 15h RLUnCompVram 22 16h Diff8bitUnFilterWram 23 17h Diff8bitUnFilterVram 24 18h Diff16bitUnFilter 25 19h SoundBias 26 1Ah SoundDriverInit 27 1Bh SoundDriverMode 28 1Ch SoundDriverMain 29 1Dh SoundDriverVSync 30 1Eh SoundChannelClear 31 1Fh MidiKey2Freq 32-36 20h-24h -Undoc- (Sound Related ???) 37 25h MultiBoot 38 26h -Undoc- ("HardReset") 39 27h -Undoc- ("CustomHalt") 40 28h SoundDriverVSyncOff 41 29h SoundDriverVSyncOn 42 2Ah -Undoc- ("GetJumpList" for Sound ???) 43-255 2Bh-FFh -Not used- |
BIOS Arithmetic Functions |
r0 signed 32bit Number r1 signed 32bit Denom |
r0 Number DIV Denom r1 Number MOD Denom r3 ABS (Number DIV Denom) |
r0 unsigned 32bit number |
r0 unsigned 16bit number |
r0 Tan, 16bit (1bit sign, 1bit integral part, 14bit decimal part) |
r0 "-PI/2<THETA/<PI/2" in a range of C000h-4000h. |
r0 X, 16bit (1bit sign, 1bit integral part, 14bit decimal part) r1 Y, 16bit (1bit sign, 1bit integral part, 14bit decimal part) |
r0 0000h-FFFFh for 0<=THETA<2PI. |
BIOS Rotation/Scaling Functions |
r0 Pointer to Source Data Field with entries as follows: s32 Original data's center X coordinate (8bit fractional portion) s32 Original data's center Y coordinate (8bit fractional portion) s16 Display's center X coordinate s16 Display's center Y coordinate s16 Scaling ratio in X direction (8bit fractional portion) s16 Scaling ratio in Y direction (8bit fractional portion) u16 Angle of rotation (8bit fractional portion) Effective Range 0-FFFF r1 Pointer to Destination Data Field with entries as follows: s16 Difference in X coordinate along same line s16 Difference in X coordinate along next line s16 Difference in Y coordinate along same line s16 Difference in Y coordinate along next line s32 Start X coordinate s32 Start Y coordinate r2 Number of Calculations |
r0 Source Address, pointing to data structure as such: s16 Scaling ratio in X direction (8bit fractional portion) s16 Scaling ratio in Y direction (8bit fractional portion) u16 Angle of rotation (8bit fractional portion) Effective Range 0-FFFF r1 Destination Address, pointing to data structure as such: s16 Difference in X coordinate along same line s16 Difference in X coordinate along next line s16 Difference in Y coordinate along same line s16 Difference in Y coordinate along next line r2 Number of calculations r3 Offset in bytes for parameter addresses (2=contigiously, 8=OAM) |
BIOS Decompression Functions |
r0 Source Address (no alignment required) r1 Destination Address (must be 32bit-word aligned) r2 Pointer to UnPack information: 16bit Length of Source Data in bytes (0-FFFFh) 8bit Width of Source Units in bits (only 1,2,4,8 supported) 8bit Width of Destination Units in bits (only 1,2,4,8,16,32 supported) 32bit Data Offset (Bit 0-30), and Zero Data Flag (Bit 31) The Data Offset is always added to all non-zero source units. If the Zero Data Flag was set, it is also added to zero units. |
unfiltered: 10 11 12 13 14 15 16 17 18 19 filtered: 10 +1 +1 +1 +1 +1 +1 +1 +1 +1 |
r0 Source address (must be aligned by 4) pointing to data as follows: Data Header (32bit) Bit 0-3 Data size (must be 1 for Diff8bit, 2 for Diff16bit) Bit 4-7 Type (must be 8 for DiffFiltered) Bit 8-31 24bit size after decompression Data Units (each 8bit or 16bit depending on used SWI function) Data0 ;original data Data1-Data0 ;difference data Data2-Data1 ;... Data3-Data2 ... r1 Destination address |
r0 Source Address, aligned by 4, pointing to: Data Header (32bit) Bit 0-3 Data size in bit units (normally 4 or 8) Bit 4-7 Compressed type (must be 2 for Huffman) Bit 8-31 24bit size of decompressed data in bytes Tree Table u8 tree table size/2-1 Each of the nodes below defined as: u8 6bit offset to next node -1 (2 byte units) 1bit right node end flag (if set, data is in next node) 1bit left node end flag 1 node Root node 2 nodes Left, and Right node 4 nodes LeftLeft, LeftRight, RightLeft, and RightRight node ... Compressed data ... r1 Destination Address |
r0 Source address, pointing to data as such: Data header (32bit) Bit 0-3 Reserved Bit 4-7 Compressed type (must be 1 for LZ77) Bit 8-31 Size of decompressed data Repeat below. Each Flag Byte followed by eight Blocks. Flag data (8bit) Bit 0-7 Type Flags for next 8 Blocks, MSB first Block Type 0 - Uncompressed - Copy 1 Byte from Source to Dest Bit 0-7 One data byte to be copied to dest Block Type 1 - Compressed - Copy N+3 Bytes from Dest-Disp-1 to Dest Bit 0-3 Disp MSBs Bit 4-7 Number of bytes to copy (minus 3) Bit 8-15 Disp LSBs r1 Destination address |
r0 Source Address, pointing to data as such: Data header (32bit) Bit 0-3 Reserved Bit 4-7 Compressed type (must be 3 for run-length) Bit 8-31 Size of decompressed data Repeat below. Each Flag Byte followed by one or more Data Bytes. Flag data (8bit) Bit 0-6 Expanded Data Length (uncompressed N-1, compressed N-3) Bit 7 Flag (0=uncompressed, 1=compressed) Data Byte(s) - N uncompressed bytes, or 1 byte repeated N times r1 Destination Address |
BIOS Memory Copy |
r0 Source address (must be aligned by 4) r1 Destination address (must be aligned by 4) r2 Length/Mode Bit 0-15 Wordcount (must be multiple of 8 WORDs, ie. 32 bytes) Bit 24 Fixed Source Address (0=Copy, 1=Fill by WORD[r0]) |
r0 Source address (must be aligned by 4 for 32bit, by 2 for 16bit) r1 Destination address (must be aligned by 4 for 32bit, by 2 for 16bit) r2 Length/Mode Bit 0-15 Wordcount (for 32bit), or Halfwordcount (for 16bit) Bit 24 Fixed Source Address (0=Copy, 1=Fill by {HALF}WORD[r0]) Bit 26 Datasize (0=16bit, 1=32bit) |
BIOS Halt Functions |
r0 0=Return immediately if an old flag was already set. 1=Discard old flags, wait until a NEW flag becomes set. r1 Specification of IE/IF interrupt flag(s) to wait for. |
BIOS Reset Functions |
[3007FFAh] Return Address Select (00h for 8000000h, 01h-FFh for 2000000h) |
r0 ResetFlags Bit Expl. 0 Clear 256K on-board WRAM ;-don't use when returning to WRAM 1 Clear 32K in-chip WRAM ;-excluding last 200h bytes 2 Clear Palette 3 Clear VRAM 4 Clear OAM ;-zerofilled! does NOT disable OBJs! 5 Reset SIO registers ;-switches to general purpose mode! 6 Reset Sound registers 7 Reset all other registers (except SIO, Sound) |
BIOS Multi Boot (Single Game Pak) |
r7 Pointer to MultiBootParam structure r1 Transfer Mode (undocumented) 0=256KHz, 32bit, Normal mode (fast and stable) 1=115KHz, 16bit, MultiPlay mode (default, slow, up to three slaves) 2=2MHz, 32bit, Normal mode (fastest but maybe unstable) Note: HLL-programmers that are using the MultiBoot(param_ptr) macro cannot specify the transfer mode and will be forcefully using MultiPlay mode. |
r0 0=okay, 1=failed |
Addr Size Name/Expl. 14h 1 handshake_data (entry used for normal mode only) 19h 3 client_data[1,2,3] 1Ch 1 palette_data 1Eh 1 client_bit (Bit 1-3 set if child 1-3 detected) 20h 4 boot_srcp (typically 8000000h+0C0h) 24h 4 boot_endp (typically 8000000h+0C0h+length) |
Times Send Receive Expl. -----------------------Required Transfer Initiation in master program ... 6200 FFFF Slave not in multiplay/normal mode yet 1 6200 0000 Slave entered correct mode now 15 6200 720x Repeat 15 times, if failed: delay 1/16s and restart 1 610y 720x Recognition okay, exchange master/slave info 60h xxxx NN0x Transfer C0h bytes header data in units of 16bits 1 6200 000x Transfer of header data completed 1 620y 720x Exchange master/slave info again ... 63pp 720x Wait until all slaves reply 73cc instead 720x 1 63pp 73cc Send palette_data and receive client_data[1-3] 1 64hh 73uu Send handshake_data for final transfer completion -----------------------Below is SWI 37 MultiBoot handler in BIOS DELAY - - Wait 1/16 seconds at master side 1 llll 73rr Send length information and receive random data[1-3] LEN yyyy nnnn Transfer main data block in units of 16 or 32 bits 1 0065 nnnn Transfer of main data block completed, request CRC ... 0065 0074 Wait until all slaves reply 0075 instead 0074 1 0065 0075 All slaves ready for CRC transfer 1 0066 0075 Signalize that transfer of CRC follows 1 zzzz zzzz Exchange CRC must be same for master and slaves -----------------------Optional Handshake (NOT part of master/slave BIOS) ... .... .... Exchange whatever custom data |
y client_bit, bit(s) 1-3 set if slave(s) 1-3 detected x bit 1,2,or 3 set if slave 1,2,or 3 xxxx header data, transferred in 16bit (!) units (even in 32bit normal mode) nn response value for header transfer, decreasing 60h..01h pp palette_data cc random client_data[1..3] from slave 1-3, FFh if slave not exists hh handshake_data, 11h+client_data[1]+client_data[2]+client_data[3] uu random data, not used, ignore this value |
llll download length/4-34h rr random data from each slave for encryption, FFh if slave not exists yyyy encoded data in 16bit (multiplay) or 32bit (normal mode) units nnnn response value, lower 16bit of destadr in GBA memory (00C0h and up) zzzz 16bit download CRC value, must be same for master and slaves |
BIOS Sound Functions |
r0 WaveData* wa r1 u8 mk r2 u8 fp |
r0 u32 |
r0 BIAS level (0=Level 000h, any other value=Level 200h) |
r0 Pointer to work area for sound driver, SoundArea structure as follows: SoundArea (sa) Structure u32 ident Flag the system checks to see whether the work area has been initialized and whether it is currently being accessed. vu8 DmaCount User access prohibited u8 reverb Variable for applying reverb effects to direct sound u16 d1 User access prohibited void (*func)() User access prohibited int intp User access prohibited void* NoUse User access prohibited SndCh vchn[MAX] The structure array for controlling the direct sound channels (currently 8 channels are available). The term "channel" here does not refer to hardware channels, but rather to virtual constructs inside the sound driver. s8 pcmbuf[PCM_BF*2] SoundChannel Structure u8 sf The flag indicating the status of this channel. When 0 sound is stopped. To start sound, set other parameters and then write 80h to here. To stop sound, logical OR 40h for a release-attached off (key-off), or write zero for a pause. The use of other bits is prohibited. u8 r1 User access prohibited u8 rv Sound volume output to right side u8 lv Sound volume output to left side u8 at The attack value of the envelope. When the sound starts, the volume begins at zero and increases every 1/60 second. When it reaches 255, the process moves on to the next decay value. u8 de The decay value of the envelope. It is multiplied by "this value/256" every 1/60 sec. and when sustain value is reached, the process moves to the sustain condition. u8 su The sustain value of the envelope. The sound is sustained by this amount. (Actually, multiplied by rv/256, lv/256 and output left and right.) u8 re The release value of the envelope. Key-off (logical OR 40h in sf) to enter this state. The value is multiplied by "this value/256" every 1/60 sec. and when it reaches zero, this channel is completely stopped. u8 r2[4] User access prohibited u32 fr The frequency of the produced sound. Write the value obtained with the MidiKey2Freq function here. WaveData* wp Pointer to the sound's waveform data. The waveform data can be generated automatically from the AIFF file using the tool (aif2agb.exe), so users normally do not need to create this themselves. u32 r3[6] User access prohibited u8 r4[4] User access prohibited WaveData Structure u16 type Indicates the data type. This is currently not used. u16 stat At the present time, non-looped (1 shot) waveform is 0000h and forward loop is 4000h. u32 freq This value is used to calculate the frequency. It is obtained using the following formula: sampling rate x 2^((180-original MIDI key)/12) u32 loop Loop pointer (start of loop) u32 size Number of samples (end position) s8 data[] The actual waveform data. Takes (number of samples+1) bytes of 8bit signed linear uncompressed data. The last byte is zero for a non-looped waveform, and the same value as the loop pointer data for a looped waveform. |
r0 Sound driver operation mode Bit Expl. 0-6 Direct Sound Reverb value (0-127, default=0) (ignored if Bit7=0) 7 Direct Sound Reverb set (0=ignore, 1=apply reverb value) 8-11 Direct Sound Simultaneously-produced (1-12 channels, default 8) 12-15 Direct Sound Master volume (1-15, default 15) 16-19 Direct Sound Playback Frequency (1-12 = 5734,7884,10512,13379, 15768,18157,21024,26758,31536,36314,40137,42048, def 4=13379 Hz) 20-23 Final number of D/A converter bits (8-11 = 9-6bits, def. 9=8bits) 24-31 Not used. |
Unpredictable Things |
External Connectors |
AUX Game Pak Bus |
Pin Name Dir Expl. 1 VDD O Power Supply 3.3V DC 2 PHI O System Clock (selectable none, 4.19MHz, 8.38MHz, 16.76MHz) 3 /WR O Write Select 4 /RD O Read Select 5 /CS O ROM Chip Select 6-21 AD0-15 I/O lower 16bit Address and/or 16bit ROM-data (see below) 22-29 A16-23 I/O upper 8bit ROM-Address or 8bit SRAM-data (see below) 30 /CS2 O SRAM Chip Select 31 /REQ I Interrupt request (/IREQ) or DMA request (/DREQ) 32 GND O Ground 0V |
AUX Link Port |
Pin Name Cable 1 VDD35 N/A 2 SO Red 3 SI Orange 4 SD Brown 5 SC Green 6 GND Blue Shield Shield |
Big Plug Middle Socket Small Plug Plug 1 Plug 2 SI-----------------+ +-------SI SI-------\/------SI SO-------------SO +--|-------SO SO-------/\------SO GND------------GND----+------GND GND-------------GND SD-------------SD-------------SD SD SD SC-------------SC-------------SC SC---------------SC Shield-------Shield-------Shield Shield-------Shield |
AUX Sound/Headphone Socket |
Pin Expl. Tip Sound Left Middle Sound Right Base Ground |
AUX Battery/Power Supply |
PC +5V (red) --------|>|---|>|-------- GBA BT+ PC GND (black) ------------------------- GBA BT- |
AUX Opening the GBA |
AUX Mainboard |
AUX Multiboot PC-to-GBA Cable |
GBA Name Color SUBD CNTR Name 2 SO Red ------------- 10 10 /ACK 3 SI Orange ------------- 14 14 /AUTOLF 5 SC Green ------------- 1 1 /STROBE 6 GND Blue ------------- 19 19 GND |
4 SD Brown ------------- 17 36 /SELECT (double speed burst) - - - +----------- 2..9 2..9 D0..7 (pull-up) - - - |---[===]--- 14 14 /AUTOLF (pull-up) - - - |---[===]--- 1 1 /STROBE (pull-up) - - - +---[===]--- 17 36 /SELECT (pull-up) RESET (mainboard) ------|>|---- 16 31 /INIT (automatic reset) |
Boot Mode_____Delay 0_______Delay 1_______Delay 2_____ Double Burst 0.1s - 1.8s 0.1s - 3.7s 0.1s - 5.3s Single Burst 0.1s - 3.6s 0.1s - 7.1s 0.1s - 10.6s Normal Bios 4.0s - 9.0s 4.0s - 12.7s 4.0s - 16.3s |
1) Connect it to the GBA link port. Advantage: No need to open/modify the GBA. Disadvantage: You need a special plug, (typically gained by removing it from a gameboy link cable). 2) Solder the cable directly to the GBA link port pins. Advantages: No plug required & no need to open the GBA. Disadvantages: You can't remove the cable, and the link port becomes unusable. 3) Solder the cable directly to the GBA mainboard. Advantage: No plug required at the GBA side. Disadvantage: You'll always have a cable leaping out of the GBA even when not using it, unless you put a small standard plug between GBA and cable. 4) Install a Centronics socket in the GBA (between power switch and headphone socket). Advantage: You can use a standard printer cable. Disadvantages: You need to cut a big hole into the GBAs battery box (which cannot be used anymore), the big cable might be a bit uncomfortable when holding the GBA. |
AUX Burst Boot Backdoor |
Send (PC) Reply (GBA) "BRST" "BOOT" ;request burst, and reply <prepared> for boot <wait 1/16s> <process IRQ> ;long delay, allow slave to enter IRQ handler llllllll "OKAY" ;send length in bytes, reply <ready> to boot dddddddd -------- ;send data in 32bit units, reply don't care cccccccc cccccccc ;exchange crc (all data units added together) |
.arm ;select 32bit ARM instruction set .gba ;indicate that it's a gameboy advance program .fix ;automatically fix the cartridge header checksum org 2000000h ;origin in RAM for multiboot-cable/no$gba-cutdown programs ;------------------ ;cartridge header/multiboot header b rom_start ;-rom entry point dcb ...insert logo here... ;-nintento logo (156 bytes) dcb 'XBOO SAMPLE ' ;-title (12 bytes) dcb 0,0,0,0, 0,0 ;-game code (4 bytes), maker code (2 bytes) dcb 96h,0,0 ;-fixed value 96h, main unit code, device type dcb 0,0,0,0,0,0,0 ;-reserved (7 bytes) dcb 0 ;-software version number dcb 0 ;-header checksum (set by .fix) dcb 0,0 ;-reserved (2 bytes) b ram_start ;-multiboot ram entry point dcb 0,0 ;-multiboot reserved bytes (destroyed by BIOS) dcb 0,0 ;-blank padded (32bit alignment) ;------------------ irq_handler: ;interrupt handler (note: r0-r3 are pushed by BIOS) mov r1,4000000h ;\get I/O base address, ldr r0,[r1,200h] ;IE/IF ; read IE and IF, and r0,r0,r0,lsr 16 ; isolate occurred AND enabled irqs, add r3,r1,200h ;IF ; and acknowledge these in IF strh r0,[r3,2] ;/ ldrh r3,[r1,-8] ;\mix up with BIOS irq flags at 3007FF8h, orr r3,r3,r0 ; aka mirrored at 3FFFFF8h, this is required strh r3,[r1,-8] ;/when using the (VBlank-)IntrWait functions and r3,r0,80h ;IE/IF.7 SIO ;\ cmp r3,80h ; check if it's a burst boot interrupt ldreq r2,[r1,120h] ;SIODATA32 ; (if interrupt caused by serial transfer, ldreq r3,[msg_brst] ; and if received data is "BRST", cmpeq r2,r3 ; then jump to burst boot) beq burst_boot ;/ ;... insert your own interrupt handler code here ... bx lr ;-return to the BIOS interrupt handler ;------------------ burst_boot: ;requires incoming r1=4000000h ;... if your program uses DMA, disable any active DMA transfers here ... ldr r4,[msg_okay] ;\ bl sio_transfer ; receive transfer length/bytes & reply "OKAY" mov r2,r0 ;len ;/ mov r3,3000000h ;dst ;\ mov r4,0 ;crc ; @@lop: ; bl sio_transfer ; download burst loader to 3000000h and up stmia [r3]!,r0 ;dst ; add r4,r4,r0 ;crc ; subs r2,r2,4 ;len ; bhi @@lop ;/ bl sio_transfer ;-send crc value to master b 3000000h ;ARM state! ;-launch actual transfer / start the loader ;------------------ sio_transfer: ;serial transfer subroutine, 32bit normal mode, external clock str r4,[r1,120h] ;siodata32 ;-set reply/send data ldr r0,[r1,128h] ;siocnt ;\ orr r0,r0,80h ; activate slave transfer str r0,[r1,128h] ;siocnt ;/ @@wait: ;\ ldr r0,[r1,128h] ;siocnt ; wait until transfer completed tst r0,80h ; bne @@wait ;/ ldr r0,[r1,120h] ;siodata32 ;-get received data bx lr ;--- msg_boot dcb 'BOOT' ;\ msg_okay dcb "OKAY" ; ID codes for the burstboot protocol msg_brst dcb "BRST" ;/ ;------------------ download_rom_to_ram: mov r0,8000000h ;src/rom ;\ mov r1,2000000h ;dst/ram ; mov r2,40000h/16 ;length ; transfer the ROM content @@lop: ; into RAM (done in units of 4 words/16 bytes) ldmia [r0]!,r4,r5,r6,r7 ; currently fills whole 256K of RAM, stmia [r1]!,r4,r5,r6,r7 ; even though the proggy is smaller subs r2,r2,1 ; bne @@lop ;/ sub r15,lr,8000000h-2000000h ;-return (retadr rom/8000XXXh -> ram/2000XXXh) ;------------------ init_interrupts: mov r4,4000000h ;-base address for below I/O registers ldr r0,=irq_handler ;\install IRQ handler address str r0,[r4,-4] ;IRQ HANDLER ;/at 3FFFFFC aka 3007FFC mov r0,0008h ;\enable generating vblank irqs strh r0,[r4,4h] ;DISPSTAT ;/ mrs r0,cpsr ;\ bic r0,r0,80h ; cpu interrupt enable (clear i-flag) msr cpsr,r0 ;/ mov r0,0 ;\ str r0,[r4,134h] ;RCNT ; init SIO normal mode, external clock, ldr r0,=5080h ; 32bit, IRQ enable, transfer started str r0,[r4,128h] ;SIOCNT ; output "BOOT" (indicate burst boot prepared) ldr r0,[msg_boot] ; str r0,[r4,120h] ;SIODATA32 ;/ mov r0,1 ;\interrupt master enable str r0,[r4,208h] ;IME=1 ;/ mov r0,81h ;\enable execution of vblank IRQs, str r0,[r4,200h] ;IE=81h ;/and of SIO IRQs (burst boot) bx lr ;------------------ rom_start: ;entry point when booted from flashcart/rom bl download_rom_to_ram ;-download ROM to RAM (returns to ram_start) ram_start: ;entry point for multiboot/burstboot mov r0,0feh ;\reset all registers, and clear all memory swi 10000h ;RegisterRamReset ;/(except program code in wram at 2000000h) bl init_interrupts ;-install burst boot irq handler mov r4,4000000h ;\enable video, strh r4,[r4,000h] ;DISPCNT ;/by clearing the forced blank bit @@mainloop: swi 50000h ;VBlankIntrWait ;-wait one frame (cpu in low power mode) mov r5,5000000h ;\increment the backdrop palette color str r8,[r5] ; (ie. display a blinking screen) add r8,r8,1 ;/ b @@mainloop ;------------------ .pool end |
CPU Reference |
CPU Overview |
8bit - Byte 16bit - Halfword 32bit - Word |
- Each single opcode provides more functionality, resulting in faster execution when using a 32bit bus memory system (such like opcodes stored in GBA Work RAM). - All registers R0-R15 can be accessed directly. |
- Not so fast when using 16bit memory system (but it still works though). - Program code occupies more memory space. |
- Faster execution up to approx 160% when using a 16bit bus memory system (such like opcodes stored in GBA GamePak ROM). - Reduces code size, decreases memory overload down to approx 65%. |
- Not as multi-functional opcodes as in ARM state, so it will be sometimes required use more than one opcode to gain a similiar result as for a single opcode in ARM state. - Most opcodes allow only registers R0-R7 to be used directly. |
CPU Register Set |
System/User FIQ Supervisor Abort IRQ Undefined -------------------------------------------------------------- R0 R0 R0 R0 R0 R0 R1 R1 R1 R1 R1 R1 R2 R2 R2 R2 R2 R2 R3 R3 R3 R3 R3 R3 R4 R4 R4 R4 R4 R4 R5 R5 R5 R5 R5 R5 R6 R6 R6 R6 R6 R6 R7 R7 R7 R7 R7 R7 -------------------------------------------------------------- R8 R8_fiq R8 R8 R8 R8 R9 R9_fiq R9 R9 R9 R9 R10 R10_fiq R10 R10 R10 R10 R11 R11_fiq R11 R11 R11 R11 R12 R12_fiq R12 R12 R12 R12 R13 (SP) R13_fiq R13_svc R13_abt R13_irq R13_und R14 (LR) R14_fiq R14_svc R14_abt R14_irq R14_und R15 (PC) R15 R15 R15 R15 R15 -------------------------------------------------------------- CPSR CPSR CPSR CPSR CPSR CPSR -- SPSR_fiq SPSR_svc SPSR_abt SPSR_irq SPSR_und -------------------------------------------------------------- |
CPU Flags |
Bit Expl. 31 N - Sign Flag (0=Not Signed, 1=Signed) 30 Z - Zero Flag (0=Not Zero, 1=Zero) 29 C - Carry Flag (0=No Carry, 1=Carry) 28 V - Overflow Flag (0=No Overflow, 1=Overflow) 27-8 Reserved (For future use) - Do not change manually! 7 I - IRQ disable (0=Enable, 1=Disable) 6 F - FIQ disable (0=Enable, 1=Disable) 5 T - State Bit (0=ARM, 1=THUMB) - Do not change manually! 4-0 M4-M0 - Mode Bits (See below) |
Binary Hex Dec Expl. 10000b 10h 16 - User (non-privileged) 10001b 11h 17 - FIQ 10010b 12h 18 - IRQ 10011b 13h 19 - Supervisor (SWI) 10111b 17h 23 - Abort 11011b 1Bh 27 - Undefined 11111b 1Fh 31 - System (privileged 'User' mode) |
CPU Exceptions |
Address Exception Mode on Entry 00000000h Reset Supervisor (_svc) 00000004h Undefined Instruction Undefined (_und) 00000008h Software Interrupt (SWI) Supervisor (_svc) 0000000Ch Prefetch Abort Abort (_abt) 00000010h Data Abort Abort (_abt) 00000014h (Reserved) - - 00000018h Normal Interrupt (IRQ) IRQ (_irq) 0000001Ch Fast Interrupt (FIQ) FIQ (_fiq) |
- R14=PC+nn ;save old PC, ie. return address - SPSR_<new mode>=CPSR ;save old flags - CPSR new T,M bits ;set to T=0 (ARM state), and M4-0=new mode - CPSR new I,F bits ;depends of type of exception ;for FIQ: F=???,I=1, and for IRQ: F=same,I=1 - PC=exception_vector ;see table above |
SUBS PC,R14,4 ;both PC=R14_irq-4, and CPSR=SPSR_irq |
MOVS PC,R14 ;both PC=R14_svc, and CPSR=SPSR_svc |
MOVS PC,R14 ;both PC=R14_und, and CPSR=SPSR_und |
prefetch abort: SUBS PC,R14,#4 ;PC=R14_abt-4, and CPSR=SPSR_abt data abort: SUBS PC,R14,#8 ;PC=R14_abt-8, and CPSR=SPSR_abt |
THUMB Instruction Set |
THUMB Instruction Summary |
Instruction Cycles Flags Format Expl. MOV Rd,Imm8bit 1S NZ-- 3 Rd=nn MOV Rd,Rs 1S NZ00 2 Rd=Rs+0 MOV R0..14,R8..15 1S ---- 5 Rd=Rs MOV R8..14,R0..15 1S ---- 5 Rd=Rs MOV R15,R0..15 2S+1N ---- 5 PC=Rs MVN Rd,Rs 1S NZ-- 4 Rd=NOT Rs AND Rd,Rs 1S NZ-- 4 Rd=Rd AND Rs TST Rd,Rs 1S NZ-- 4 Void=Rd AND Rs BIC Rd,Rs 1S NZ-- 4 Rd=Rd AND NOT Rs ORR Rd,Rs 1S NZ-- 4 Rd=Rd OR Rs EOR Rd,Rs 1S NZ-- 4 Rd=Rd XOR Rs LSL Rd,Rs,Imm5bit 1S NZc- 1 Rd=Rs SHL nn LSL Rd,Rs 1S+1I NZc- 4 Rd=Rd SHL (Rs AND 0FFh) LSR Rd,Rs,Imm5bit 1S NZc- 1 Rd=Rs SHR nn LSR Rd,Rs 1S+1I NZc- 4 Rd=Rd SHR (Rs AND 0FFh) ASR Rd,Rs,Imm5bit 1S NZc- 1 Rd=Rs SRA nn ASR Rd,Rs 1S+1I NZc- 4 Rd=Rd SRA (Rs AND 0FFh) ROR Rd,Rs 1S+1I NZc- 4 Rd=Rd ROR (Rs AND 0FFh) NOP 1S ---- 5 R8=R8 |
Instruction Cycles Flags Format Expl. ADD Rd,Rs,Imm3bit 1S NZCV 2 Rd=Rs+nn ADD Rd,Imm8bit 1S NZCV 3 Rd=Rd+nn ADD Rd,Rs,Rn 1S NZCV 2 Rd=Rs+Rn ADD R0..14,R8..15 1S ---- 5 Rd=Rd+Rs ADD R8..14,R0..15 1S ---- 5 Rd=Rd+Rs ADD R15,R0..15 2S+1N ---- 5 PC=Rd+Rs ADD Rd,PC,Imm8bit*4 1S ---- 12 Rd=(($+4) AND NOT 2)+nn ADD Rd,SP,Imm8bit*4 1S ---- 12 Rd=SP+nn ADD SP,Imm7bit*4 1S ---- 13 SP=SP+nn ADD SP,-Imm7bit*4 1S ---- 13 SP=SP-nn ADC Rd,Rs 1S NZCV 4 Rd=Rd+Rs+Cy SUB Rd,Rs,Imm3Bit 1S NZCV 2 Rd=Rs-nn SUB Rd,Imm8bit 1S NZCV 3 Rd=Rd-nn SUB Rd,Rs,Rn 1S NZCV 2 Rd=Rs-Rn SBC Rd,Rs 1S NZCV 4 Rd=Rd-Rs-NOT Cy NEG Rd,Rs 1S NZCV 4 Rd=0-Rs CMP Rd,Imm8bit 1S NZCV 3 Void=Rd-nn CMP Rd,Rs 1S NZCV 4 Void=Rd-Rs CMP R0-15,R8-15 1S NZCV 5 Void=Rd-Rs CMP R8-15,R0-15 1S NZCV 5 Void=Rd-Rs CMN Rd,Rs 1S NZCV 4 Void=Rd+Rs MUL Rd,Rs 1S+mI NZx- 4 Rd=Rd*Rs |
Instruction Cycles Flags Format Expl. B disp 2S+1N ---- 18 PC=$+/-2048 BL disp 3S+1N ---- 19 PC=$+/-4M, LR=$+5 B{cond=true} disp 2S+1N ---- 16 PC=$+/-0..256 B{cond=false} disp 1S ---- 16 N/A BX R0..15 2S+1N ---- 5 PC=Rs, ARM/THUMB (Rs bit0) SWI Imm8bit 2S+1N ---- 17 PC=8, ARM SVC mode, LR=$+2 POP {Rlist,}PC (n+1)S+2N+1I ---- 14 MOV R15,R0..15 2S+1N ---- 5 PC=Rs ADD R15,R0..15 2S+1N ---- 5 PC=Rd+Rs |
Instruction Cycles Flags Format Expl. LDR Rd,[Rb,5bit*4] 1S+1N+1I ---- 9 Rd = WORD[Rb+nn] LDR Rd,[PC,8bit*4] 1S+1N+1I ---- 6 Rd = WORD[PC+nn] LDR Rd,[SP,8bit*4] 1S+1N+1I ---- 11 Rd = WORD[SP+nn] LDR Rd,[Rb,Ro] 1S+1N+1I ---- 7 Rd = WORD[Rb+Ro] LDRB Rd,[Rb,5bit*1] 1S+1N+1I ---- 9 Rd = BYTE[Rb+nn] LDRB Rd,[Rb,Ro] 1S+1N+1I ---- 7 Rd = BYTE[Rb+Ro] LDRH Rd,[Rb,5bit*2] 1S+1N+1I ---- 10 Rd = HALFWORD[Rb+nn] LDRH Rd,[Rb,Ro] 1S+1N+1I ---- 8 Rd = HALFWORD[Rb+Ro] LDSB Rd,[Rb,Ro] 1S+1N+1I ---- 8 Rd = SIGNED_BYTE[Rb+Ro] LDSH Rd,[Rb,Ro] 1S+1N+1I ---- 8 Rd = SIGNED_HALFWORD[Rb+Ro] STR Rd,[Rb,5bit*4] 2N ---- 9 WORD[Rb+nn] = Rd STR Rd,[SP,8bit*4] 2N ---- 11 WORD[SP+nn] = Rd STR Rd,[Rb,Ro] 2N ---- 7 WORD[Rb+Ro] = Rd STRB Rd,[Rb,5bit*1] 2N ---- 9 BYTE[Rb+nn] = Rd STRB Rd,[Rb,Ro] 2N ---- 7 BYTE[Rb+Ro] = Rd STRH Rd,[Rb,5bit*2] 2N ---- 10 HALFWORD[Rb+nn] = Rd STRH Rd,[Rb,Ro] 2N ---- 8 HALFWORD[Rb+Ro]=Rd PUSH {Rlist}{LR} (n-1)S+2N ---- 14 POP {Rlist}{PC} ---- 14 STMIA Rb!,{Rlist} (n-1)S+2N ---- 15 LDMIA Rb!,{Rlist} nS+1N+1I ---- 15 |
Form|_15|_14|_13|_12|_11|_10|_9_|_8_|_7_|_6_|_5_|_4_|_3_|_2_|_1_|_0_| __1_|_0___0___0_|__Op___|_______Offset______|____Rs_____|____Rd_____|Shifted __2_|_0___0___0___1___1_|_I,_Op_|___Rn/nn___|____Rs_____|____Rd_____|ADD/SUB __3_|_0___0___1_|__Op___|____Rd_____|_____________Offset____________|Immedi. __4_|_0___1___0___0___0___0_|______Op_______|____Rs_____|____Rd_____|AluOp __5_|_0___1___0___0___0___1_|__Op___|Hd_|Hs_|____Rs_____|____Rd_____|HiReg/BX __6_|_0___1___0___0___1_|____Rd_____|_____________Word______________|LDR PC __7_|_0___1___0___1_|__Op___|_0_|___Ro______|____Rb_____|____Rd_____|LDR/STR __8_|_0___1___0___1_|__Op___|_1_|___Ro______|____Rb_____|____Rd_____|""H/SB/SH __9_|_0___1___1_|__Op___|_______Offset______|____Rb_____|____Rd_____|""{B} _10_|_1___0___0___0_|Op_|_______Offset______|____Rb_____|____Rd_____|""H _11_|_1___0___0___1_|Op_|____Rd_____|_____________Word______________|"" SP _12_|_1___0___1___0_|Op_|____Rd_____|_____________Word______________|ADD PC/SP _13_|_1___0___1___1___0___0___0___0_|_S_|___________Word____________|ADD SP,nn _14_|_1___0___1___1_|Op_|_1___0_|_R_|____________Rlist______________|PUSH/POP _15_|_1___1___0___0_|Op_|____Rb_____|____________Rlist______________|STM/LDM _16_|_1___1___0___1_|_____Cond______|_________Signed_Offset_________|B{cond} _17_|_1___1___0___1___1___1___1___1_|___________User_Data___________|SWI _18_|_1___1___1___0___0_|________________Offset_____________________|B _19_|_1___1___1___1_|_H_|______________Offset_Low/High______________|BL |
THUMB.1: move shifted register |
Bit Expl. 15-13 Must be 000b for 'move shifted register' instructions 12-11 Opcode 00b: LSL Rd,Rs,#Offset (logical/arithmetic shift left) 01b: LSR Rd,Rs,#Offset (logical shift right) 10b: ASR Rd,Rs,#Offset (arithmetic shift right) 11b: Reserved (used for add/subtract instructions) 10-6 Offset (0-31) 5-3 Rs - Source register (R0..R7) 2-0 Rd - Destination register (R0..R7) |
THUMB.2: add/subtract |
Bit Expl. 15-11 Must be 00011b for 'add/subtract' instructions 10-9 Opcode (0-3) 0: ADD Rd,Rs,Rn ;add register Rd=Rs+Rn 1: SUB Rd,Rs,Rn ;subtract register Rd=Rs-Rn 2: ADD Rd,Rs,#nn ;add immediate Rd=Rs+nn 3: SUB Rd,Rs,#nn ;subtract immediate Rd=Rs-nn Pseudo/alias opcode with Imm=0: 2: MOV Rd,Rs ;move (affects cpsr) Rd=Rs+0 8-6 For Register Operand: Rn - Register Operand (R0..R7) For Immediate Operand: nn - Immediate Value (0-7) 5-3 Rs - Source register (R0..R7) 2-0 Rd - Destination register (R0..R7) |
THUMB.3: move/compare/add/subtract immediate |
Bit Expl. 15-13 Must be 001b for this type of instructions 12-11 Opcode 00b: MOV Rd,#nn ;move Rd = #nn 01b: CMP Rd,#nn ;compare Void = Rd - #nn 10b: ADD Rd,#nn ;add Rd = Rd + #nn 11b: SUB Rd,#nn ;subtract Rd = Rd - #nn 10-8 Rd - Destination Register (R0..R7) 7-0 nn - Unsigned Immediate (0-255) |
THUMB.4: ALU operations |
Bit Expl. 15-10 Must be 010000b for this type of instructions 9-6 Opcode (0-Fh) 0: AND Rd,Rs ;AND logical Rd = Rd AND Rs 1: EOR Rd,Rs ;XOR logical Rd = Rd XOR Rs 2: LSL Rd,Rs ;log. shift left Rd = Rd << (Rs AND 0FFh) 3: LSR Rd,Rs ;log. shift right Rd = Rd >> (Rs AND 0FFh) 4: ASR Rd,Rs ;arit shift right Rd = Rd SRA Rs 5: ADC Rd,Rs ;add with carry Rd = Rd + Rs + Cy 6: SBC Rd,Rs ;sub with carry Rd = Rd - Rs - NOT Cy 7: ROR Rd,Rs ;rotate right Rd = Rd ROR (Rs AND 0FFh) 8: TST Rd,Rs ;test Void = Rd AND (Rs AND 0FFh) 9: NEG Rd,Rs ;negate Rd = 0 - Rs A: CMP Rd,Rs ;compare Void = Rd - Rs B: CMN Rd,Rs ;neg.compare Void = Rd + Rs C: ORR Rd,Rs ;OR logical Rd = Rd OR Rs D: MUL Rd,Rs ;multiply Rd = Rd * Rs E: BIC Rd,Rs ;bit clear Rd = Rd AND NOT Rs F: MVN Rd,Rs ;not Rd = NOT Rs 5-3 Rs - Source Register (R0..R7) 2-0 Rd - Destination Register (R0..R7) |
N,Z,C,V for ADC,SBC,NEG,CMP,CMN N,Z,C for LSL,LSR,ASR,ROR (carry flag unchanged if zero shift amount) N,Z,C for MUL (carry flag destroyed) N,Z for AND,EOR,TST,ORR,BIC,MVN |
1S for AND,EOR,ADC,SBC,TST,NEG,CMP,CMN,ORR,BIC,MVN 1S+1I for LSL,LSR,ASR,ROR 1S+mI for MUL (m=1..4 depending on MSBs of incoming Rd value) |
THUMB.5: Hi register operations/branch exchange |
Bit Expl. 15-10 Must be 010001b for this type of instructions 9-8 Opcode (0-3) 0: ADD Rd,Rs ;add Rd = Rd+Rs 1: CMP Rd,Rs ;compare Void = Rd-Rs ;CPSR affected 2: MOV Rd,Rs ;move Rd = Rs 3: BX Rs ;jump PC = Rs ;may switch THUMB/ARM 7 MSBd - Destination Register most significant bit 6 MSBs - Source Register most significant bit 5-3 Rs - Source Register (together with MSBs: R0..R15) 2-0 Rd - Destination Register (together with MSBd: R0..R15) |
Processor will be switched into ARM mode! If so, Bit 1 of Rs must be cleared (32bit word aligned). Thus, BX PC (switch to ARM) may be issued from word-aligned address only, the destination is PC+4 (ie. the following halfword is skipped). |
1S for ADD/MOV/CMP 2S+1N for ADD/MOV with Rd=R15, and for BX |
THUMB.6: load PC-relative |
Bit Expl. 15-11 Must be 01001b for this type of instructions N/A Opcode (fixed) LDR Rd,[PC,#nn] ;load 32bit Rd = WORD[PC+nn] 10-8 Rd - Destination Register (R0..R7) 7-0 nn - Unsigned offset (0-1020 in steps of 4) |
THUMB.7: load/store with register offset |
Bit Expl. 15-12 Must be 0101b for this type of instructions 11-10 Opcode (0-3) 0: STR Rd,[Rb,Ro] ;store 32bit data WORD[Rb+Ro] = Rd 1: STRB Rd,[Rb,Ro] ;store 8bit data BYTE[Rb+Ro] = Rd 2: LDR Rd,[Rb,Ro] ;load 32bit data Rd = WORD[Rb+Ro] 3: LDRB Rd,[Rb,Ro] ;load 8bit data Rd = BYTE[Rb+Ro] 9 Must be zero (0) for this type of instructions 8-6 Ro - Offset Register (R0..R7) 5-3 Rb - Base Register (R0..R7) 2-0 Rd - Source/Destination Register (R0..R7) |
THUMB.8: load/store sign-extended byte/halfword |
Bit Expl. 15-12 Must be 0101b for this type of instructions 11-10 Opcode (0-3) 0: STRH Rd,[Rb,Ro] ;store 16bit data HALFWORD[Rb+Ro] = Rd 1: LDSB Rd,[Rb,Ro] ;load sign-extended 8bit Rd = BYTE[Rb+Ro] 2: LDRH Rd,[Rb,Ro] ;load zero-extended 16bit Rd = HALFWORD[Rb+Ro] 3: LDSH Rd,[Rb,Ro] ;load sign-extended 16bit Rd = HALFWORD[Rb+Ro] 9 Must be set (1) for this type of instructions 8-6 Ro - Offset Register (R0..R7) 5-3 Rb - Base Register (R0..R7) 2-0 Rd - Source/Destination Register (R0..R7) |
THUMB.9: load/store with immediate offset |
Bit Expl. 15-13 Must be 011b for this type of instructions 12-11 Opcode (0-3) 0: STR Rd,[Rb,#nn] ;store 32bit data WORD[Rb+nn] = Rd 1: LDR Rd,[Rb,#nn] ;load 32bit data Rd = WORD[Rb+nn] 2: STRB Rd,[Rb,#nn] ;store 8bit data BYTE[Rb+nn] = Rd 3: LDRB Rd,[Rb,#nn] ;load 8bit data Rd = BYTE[Rb+nn] 10-6 nn - Unsigned Offset (0-31 for BYTE, 0-124 for WORD) 5-3 Rb - Base Register (R0..R7) 2-0 Rd - Source/Destination Register (R0..R7) |
THUMB.10: load/store halfword |
Bit Expl. 15-12 Must be 1000b for this type of instructions 11 Opcode (0-1) 0: STRH Rd,[Rb,#nn] ;store 16bit data HALFWORD[Rb+nn] = Rd 1: LDRH Rd,[Rb,#nn] ;load 16bit data Rd = HALFWORD[Rb+nn] 10-6 nn - Unsigned Offset (0-62, step 2) 5-3 Rb - Base Register (R0..R7) 2-0 Rd - Source/Destination Register (R0..R7) |
THUMB.11: load/store SP-relative |
Bit Expl. 15-12 Must be 1001b for this type of instructions 11 Opcode (0-1) 0: STR Rd,[SP,#nn] ;store 32bit data WORD[SP+nn] = Rd 1: LDR Rd,[SP,#nn] ;load 32bit data Rd = WORD[SP+nn] 10-8 Rd - Source/Destination Register (R0..R7) 7-0 nn - Unsigned Offset (0-1020, step 4) |
THUMB.12: get relative address |
Bit Expl. 15-12 Must be 1010b for this type of instructions 11 Opcode/Source Register (0-1) 0: ADD Rd,PC,#nn ;Rd = (($+4) AND NOT 2) + nn 1: ADD Rd,SP,#nn ;Rd = SP + nn 10-8 Rd - Destination Register (R0..R7) 7-0 nn - Unsigned Offset (0-1020, step 4) |
THUMB.13: add offset to stack pointer |
Bit Expl. 15-8 Must be 10110000b for this type of instructions 7 Opcode/Sign 0: ADD SP,#nn ;SP = SP + nn 1: ADD SP,#-nn ;SP = SP - nn 6-0 nn - Unsigned Offset (0-508, step 4) |
THUMB.14: push/pop registers |
Bit Expl. 15-12 Must be 1011b for this type of instructions 11 Opcode (0-1) 0: PUSH {Rlist}{LR} ;store in memory, decrements SP (R13) 1: POP {Rlist}{PC} ;load from memory, increments SP (R13) 10-9 Must be 10b for this type of instructions 8 PC/LR Bit (0-1) 0: No 1: PUSH LR (R14), or POP PC (R15) 7-0 Rlist - List of Registers (R7..R0) |
PUSH {R0-R3} ;push R0,R1,R2,R3 PUSH {R0,R2,LR} ;push R0,R2,LR POP {R4,R7} ;pop R4,R7 POP {R2-R4,PC} ;pop R2,R3,R4,PC |
THUMB.15: multiple load/store |
Bit Expl. 15-12 Must be 1100b for this type of instructions 11 Opcode (0-1) 0: STMIA Rb!,{Rlist} ;store in memory, increments Rb 1: LDMIA Rb!,{Rlist} ;load from memory, increments Rb 10-8 Rb - Base register (modified) (R0-R7) 7-0 Rlist - List of Registers (R7..R0) |
STMIA R7!,{R0-R2} ;store R0,R1,R2 LDMIA R0!,{R1,R5} ;store R1,R5 |
THUMB.16: conditional branch |
Bit Expl. 15-12 Must be 1101b for this type of instructions 11-8 Opcode/Condition (0-Fh) 0: BEQ label ;Z=1 ;equal (zero) 1: BNE label ;Z=0 ;not equal (nonzero) 2: BCS label ;C=1 ;unsigned higher or same (carry set) 3: BCC label ;C=0 ;unsigned lower (carry cleared) 4: BMI label ;N=1 ;negative (minus) 5: BPL label ;N=0 ;positive or zero (plus) 6: BVS label ;V=1 ;overflow (V set) 7: BVC label ;V=0 ;no overflowplus (V cleared) 8: BHI label ;C=1 and Z=0 ;unsigned higher 9: BLS label ;C=0 or Z=1 ;unsigned lower or same A: BGE label ;N=V ;greater or equal B: BLT label ;N<>V ;less than C: BGT label ;Z=0 and N=V ;greater than D: BLE label ;Z=1 or N<>V ;less or equal E: Undefined, should not be used F: Reserved for SWI instruction (see SWI opcode) 7-0 Signed Offset, step 2 ($+4-256..$+4+254) |
2S+1N if condition true (jump executed) 1S if condition false |
THUMB.17: software interrupt |
Bit Expl. 15-8 Must be 11011111b for this type of instructions N/A Opcode (fixed) SWI nn ;perform software interrupt 7-0 nn - Comment Immediate (0-255) |
R14_svc=PC+2 ;save return address in LR_svc SPSR_svc=CPSR ;save CPSR flags CPSR=<changed> ;Enter Supervisor mode (svc) in ARM state PC=00000008h ;jump to SWI vector address |
MOVS PC,R14 |
THUMB.18: unconditional branch |
Bit Expl. 15-11 Must be 11100b for this type of instructions N/A Opcode (fixed) B label ;branch (jump) 10-0 Signed Offset, step 2 ($+4-2048..$+4+2046) |
THUMB.19: long branch with link |
Bit Expl. 15-11 Must be 11110b for this type of instructions 10-0 nn - Upper 11 bits of Target Address |
Bit Expl. 15-11 Must be 11111b for this type of instructions 10-0 nn - Lower 11 bits of Target Address |
BL label |
ARM Instruction Set |
ARM Instruction Summary |
Instruction Cycles Flags Format Expl. MOV{cond}{S} Rd,Op2 1S+x+y NZc- 5 Rd = Op2 MVN{cond}{S} Rd,Op2 1S+x+y NZc- 5 Rd = NOT Op2 AND{cond}{S} Rd,Rn,Op2 1S+x+y NZc- 5 Rd = Rn AND Op2 TST{cond} Rn,Op2 1S+x NZc- 5 Void = Rn AND Op2 EOR{cond}{S} Rd,Rn,Op2 1S+x+y NZc- 5 Rd = Rn XOR Op2 TEQ{cond} Rn,Op2 1S+x NZc- 5 Void = Rn XOR Op2 ORR{cond}{S} Rd,Rn,Op2 1S+x+y NZc- 5 Rd = Rn OR Op2 BIC{cond}{S} Rd,Rn,Op2 1S+x+y NZc- 5 Rd = Rn AND NOT Op2 |
Instruction Cycles Flags Format Expl. ADD{cond}{S} Rd,Rn,Op2 1S+x+y NZCV 5 Rd = Rn+Op2 ADC{cond}{S} Rd,Rn,Op2 1S+x+y NZCV 5 Rd = Rn+Op2+Cy SUB{cond}{S} Rd,Rn,Op2 1S+x+y NZCV 5 Rd = Rn-Op2 SBC{cond}{S} Rd,Rn,Op2 1S+x+y NZCV 5 Rd = Rn-Op2+Cy-1 RSB{cond}{S} Rd,Rn,Op2 1S+x+y NZCV 5 Rd = Op2-Rn RSC{cond}{S} Rd,Rn,Op2 1S+x+y NZCV 5 Rd = Op2-Rn+Cy-1 CMP{cond} Rn,Op2 1S+x NZCV 5 Void = Rn-Op2 CMN{cond} Rn,Op2 1S+x NZCV 5 Void = Rn+Op2 |
Instruction Cycles Flags Format Expl. MUL{cond}{S} Rd,Rm,Rs 1S+mI NZx- 7 Rd = Rm*Rs MLA{cond}{S} Rd,Rm,Rs,Rn 1S+mI+1I NZx- 7 Rd = Rm*Rs+Rn UMULL{cond}{S} RdLo,RdHi,Rm,Rs 1S+mI+1I NZx- 8 RdHiLo = Rm*Rs UMLAL{cond}{S} RdLo,RdHi,Rm,Rs 1S+mI+2I NZx- 8 RdHiLo = Rm*Rs+RdHiLo SMULL{cond}{S} RdLo,RdHi,Rm,Rs 1S+mI+1I NZx- 8 RdHiLo = Rm*Rs SMLAL{cond}{S} RdLo,RdHi,Rm,Rs 1S+mI+2I NZx- 8 RdHiLo = Rm*Rs+RdHiLo |
Instruction Cycles Flags Format Expl. LDR{cond}{B}{T} Rd,<Address> 1S+1N+1I +y ---- 9 Rd=[Rn+/-<offset>] LDR{cond}H Rd,<Address> 1S+1N+1I +y ---- 10 Load Unsigned halfword LDR{cond}SB Rd,<Address> 1S+1N+1I +y ---- 10 Load Signed byte LDR{cond}SH Rd,<Address> 1S+1N+1I +y ---- 10 Load Signed halfword LDM{cond}{amod} Rn{!},<Rlist>{^} nS+1N+1I +y ---- 11 STR{cond}{B}{T} Rd,<Address> 2N ---- 9 [Rn+/-<offset>]=Rd STR{cond}H Rd,<Address> 2N ---- 10 Store halfword STM{cond}{amod} Rn{!},<Rlist>{^} (n-1)S+2N ---- 11 SWP{cond}{B} Rd,Rm,[Rn] 1S+2N+1I ---- 12 Rd=[Rn], [Rn]=Rm |
Instruction Cycles Flags Format Expl. B{cond} label 2S+1N ---- 4 PC=$+8+/-32M BL{cond} label 2S+1N ---- 4 PC=$+8+/-32M, LR=$+4 BX{cond} Rn 2S+1N ---- 3 PC=Rn, THUMB/ARM (Rn bit0) MRS{cond} Rd,Psr 1S ---- 6 Rd=Psr MSR{cond} Psr{_field},Op 1S (psr) 6 Psr[field]=Op SWI{cond} Imm24bit 2S+1N ---- 13 PC=8, ARM Svc mode, LR=$+4 The Undefined Instruction 2S+1I+1N ---- 17 PC=4, ARM Und mode, LR=$+4 cond=false 1S ---- .. Any opcode with condition=false NOP 1S ---- 5 R0=R0 |
Instruction Cycles Flags Format Expl. CDP{cond} p#,<cpopc>,cd,cn,cm{,<cp>} 1S+bI ---- 14 Coprocessor specific STC{cond}{L} p#,cd,<Address> (n-1)S+2N+bI 15 [address] = CRd LDC{cond}{L} p#,cd,<Address> (n-1)S+2N+bI 15 CRd = [address] MCR{cond} p#,<cpopc>,Rd,cn,cm{,<cp>} 1S+bI+1C 16 CRn = Rn {<op> CRm} MRC{cond} p#,<cpopc>,Rd,cn,cm{,<cp>} 1S+(b+1)I+1C 16 Rn = CRn {<op> CRm} |
|..3 ..................2 ..................1 ..................0| |1_0_9_8_7_6_5_4_3_2_1_0_9_8_7_6_5_4_3_2_1_0_9_8_7_6_5_4_3_2_1_0| |_Cond__|0_0|I|___Op__|S|__Rn___|__Rd___|_______Operand2________| DataProc |_Cond__|0_0|I|1_0|P|L|0|_Field_|__Rd___|_______Operand_________| PSR |_Cond__|0_0_0_1_0_0_1_0_1_1_1_1_1_1_1_1_1_1_1_1_0_0_0_1|__Rn___| BranchX |_Cond__|0_0_0_0_0_0|A|S|__Rd___|__Rn___|__Rs___|1_0_0_1|__Rm___| Multiply |_Cond__|0_0_0_0_1|U|A|S|_RdHi__|_RdLo__|__Rn___|1_0_0_1|__Rm___| MulLong |_Cond__|0_0_0_1_0|B|0_0|__Rn___|__Rd___|0_0_0_0_1_0_0_1|__Rm___| Swap |_Cond__|0_0_0|P|U|0|W|L|__Rn___|__Rd___|0_0_0_0_1|S|H|1|__Rm___| HalfTransR |_Cond__|0_0_0|P|U|1|W|L|__Rn___|__Rd___|OffsetH|1|S|H|1|OffsetL| HalfTransOf |_Cond__|0_1|I|P|U|B|W|L|__Rn___|__Rd___|_________Offset________| DataTransf |_Cond__|0_1_1|________________xxx____________________|1|__xxx__| Undefined |_Cond__|1_0_0|P|U|S|W|L|__Rn___|__________Register_List________| BlockTrans |_Cond__|1_0_1|L|___________________Offset______________________| Branch |_Cond__|1_1_0|P|U|N|W|L|__Rn___|__CRd__|__CP#__|____Offset_____| CoDataTrans |_Cond__|1_1_1_0|_CPopc_|__CRn__|__CRd__|__CP#__|_CP__|0|__CRm__| CoDataOp |_Cond__|1_1_1_0|CPopc|L|__CRn__|__Rd___|__CP#__|_CP__|1|__CRm__| CoRegTrans |_Cond__|1_1_1_1|_____________Ignored_by_Processor______________| SWI |
ARM Condition Field |
Code Suffix Flags Meaning 0: EQ Z=1 equal (zero) 1: NE Z=0 not equal (nonzero) 2: CS C=1 unsigned higher or same (carry set) 3: CC C=0 unsigned lower (carry cleared) 4: MI N=1 negative (minus) 5: PL N=0 positive or zero (plus) 6: VS V=1 overflow (V set) 7: VC V=0 no overflowplus (V cleared) 8: HI C=1 and Z=0 unsigned higher 9: LS C=0 or Z=1 unsigned lower or same A: GE N=V greater or equal B: LT N<>V less than C: GT Z=0 and N=V greater than D: LE Z=1 or N<>V less or equal E: AL - always F: Reserved, don't use |
ARM.3: Branch and Exchange (BX) |
Bit Expl. 31-28 Condition 27-4 Must be "0001.0010.1111.1111.1111.0001" for this instruction Opcode (fixed) BX{cond} Rn ;PC = Rn 3-0 Rn - Operand Register (R0-R14) |
ARM.4: Branch and Branch with Link (B, BL) |
Bit Expl. 31-28 Condition 27-25 Must be "101" for this instruction 24 Opcode (0-1) 0: B{cond} label ;branch PC=PC+8+nn 1: BL{cond} label ;branch with Link R14=PC, PC=PC+8+nn 23-0 nn - Signed Offset, step 4 (-32M..+32M in steps of 4) |
ARM.5: Data Processing |
Bit Expl. 31-28 Condition 27-26 Must be 00b for this instruction 25 I - Immediate 2nd Operand Flag (0=Register, 1=Immediate) 24-21 Opcode (0-Fh) ;*=Arithmetic, otherwise Logical 0: AND{cond}{S} Rd,Rn,Op2 ;AND logical Rd = Rn AND Op2 1: EOR{cond}{S} Rd,Rn,Op2 ;XOR logical Rd = Rn XOR Op2 2: SUB{cond}{S} Rd,Rn,Op2 ;* ;subtract Rd = Rn-Op2 3: RSB{cond}{S} Rd,Rn,Op2 ;* ;subtract reversed Rd = Op2-Rn 4: ADD{cond}{S} Rd,Rn,Op2 ;* ;add Rd = Rn+Op2 5: ADC{cond}{S} Rd,Rn,Op2 ;* ;add with carry Rd = Rn+Op2+Cy 6: SBC{cond}{S} Rd,Rn,Op2 ;* ;sub with carry Rd = Rn-Op2+Cy-1 7: RSC{cond}{S} Rd,Rn,Op2 ;* ;sub cy. reversed Rd = Op2-Rn+Cy-1 8: TST{cond} Rn,Op2 ;test Void = Rn AND Op2 9: TEQ{cond} Rn,Op2 ;test exclusive Void = Rn XOR Op2 A: CMP{cond} Rn,Op2 ;* ;compare Void = Rn-Op2 B: CMN{cond} Rn,Op2 ;* ;compare neg. Void = Rn+Op2 C: ORR{cond}{S} Rd,Rn,Op2 ;OR logical Rd = Rn OR Op2 D: MOV{cond}{S} Rd,Op2 ;move Rd = Op2 E: BIC{cond}{S} Rd,Rn,Op2 ;bit clear Rd = Rn AND NOT Op2 F: MVN{cond}{S} Rd,Op2 ;not Rd = NOT Op2 20 S - Set Condition Codes (0=No, 1=Yes) 19-16 Rn - 1st Operand Register (R0..R15) (including PC=R15) 15-12 Rd - Destination Register (R0..R15) (including PC=R15) When above Bit 25 I=0 (Register as 2nd Operand) When below Bit 4 R=0 - Shift by Immediate 11-7 Is - Shift amount (1-31, 0=Special/See below) When below Bit 4 R=1 - Shift by Register 11-8 Rs - Shift register (R0-R14) - only lower 8bit 0-255 used 7 Reserved, must be zero (otherwise multiply or undefined opcode) 6-5 Shift Type (0=LSL, 1=LSR, 2=ASR, 3=ROR) 4 R - Shift by Register Flag (0=Immediate, 1=Register) 3-0 Rm - 2nd Operand Register (R0..R15) (including PC=R15) When above Bit 25 I=1 (Immediate as 2nd Operand) 11-8 Is - ROR-Shift applied to nn (0-30, in steps of 2) 7-0 nn - 2nd Operand Unsigned 8bit Immediate |
V=not affected C=carryflag of shift operation (not affected if LSL#0 or Rs=00h) Z=zeroflag of result N=signflag of result (result bit 31) |
V=overflowflag of result C=carryflag of result Z=zeroflag of result N=signflag of result (result bit 31) |
CPSR = SPSR_<current mode> PC = result For example: MOVS PC,R14 ;return from SWI (PC=R14_svc, CPSR=SPSR_svc). |
ARM.6: PSR Transfer (MRS, MSR) |
Bit Expl. 31-28 Condition 27-26 Must be 00b for this instruction 25 I - Immediate Operand Flag (0=Register, 1=Immediate) (Zero for MRS) 24-23 Must be 10b for this instruction 22 Psr - Source/Destination PSR (0=CPSR, 1=SPSR_<current mode>) 21 Opcode 0: MRS{cond} Rd,Psr ;Rd = Psr 1: MSR{cond} Psr{_field},Op ;Psr[field] = Op 20 Must be 0b for this instruction (otherwise TST,TEQ,CMP,CMN) For MRS: 19-16 Must be 1111b for this instruction (otherwise SWP) 15-12 Rd - Destination Register (R0-R14) 11-0 Not used, must be zero. For MSR: 19 f write to flags field Bit 31-24 (aka _flg) 18 s write to status field Bit 23-16 (reserved, don't change) 17 x write to extension field Bit 15-8 (reserved, don't change) 16 c write to control field Bit 7-0 (aka _ctl) 15-12 Not used, must be 1111b. For MSR Psr,Rm (I=0) 11-4 Not used, must be zero. (otherwise BX) 3-0 Rm - Source Register <op> (R0-R14) For MSR Psr,Imm (I=1) 11-8 Shift applied to Imm (ROR in steps of two 0-30) 7-0 Imm - Unsigned 8bit Immediate In source code, a 32bit immediate should be specified as operand. The assembler should then convert that into a shifted 8bit value. |
ARM.7: Multiply and Multiply-Accumulate (MUL, MLA) |
Bit Expl. 31-28 Condition 27-22 Must be 000000b for this instruction 21 Opcode (0-1) 0: MUL{cond}{S} Rd,Rm,Rs ;multiply Rd = Rm*Rs 1: MLA{cond}{S} Rd,Rm,Rs,Rn ;multiply and accumulate Rd = Rm*Rs+Rn 20 S - Set Condition Codes (0=No, 1=Yes) 19-16 Rd - Destination Register (R0-R14) 15-12 Rn - Operand Register (R0-R14) (Used for MLA only, for MUL set to R0) 11-8 Rs - Operand Register (R0-R14) 7-4 Must be 1001b for this instruction 3-0 Rm - Operand Register (R0-R14) |
ARM.8: Multiply Long and Multiply-Accumulate Long (MULL, MLAL) |
Bit Expl. 31-28 Condition 27-23 Must be 00001b for this instruction 22-21 Opcode (0-3) 0: UMULL{cond}{S} RdLo,RdHi,Rm,Rs ;multiply RdHiLo = Rm*Rs 1: UMLAL{cond}{S} RdLo,RdHi,Rm,Rs ;mul.& acc. RdHiLo = Rm*Rs+RdHiLo 2: SMULL{cond}{S} RdLo,RdHi,Rm,Rs ;sign.mul. RdHiLo = Rm*Rs 3: SMLAL{cond}{S} RdLo,RdHi,Rm,Rs ;sign.m&a. RdHiLo = Rm*Rs+RdHiLo 20 S - Set Condition Codes (0=No, 1=Yes) 19-16 RdHi - Source/Destination Register High (R0-R14) 15-12 RdLo - Source/Destination Register Low (R0-R14) 11-8 Rs - Operand Register (R0-R14) 7-4 Must be 1001b for this instruction 3-0 Rm - Operand Register (R0-R14) |
ARM.9: Single Data Transfer (LDR, STR) |
Bit Expl. 31-28 Condition 27-26 Must be 01b for this instruction 25 I - Immediate Offset Flag (0=Immediate, 1=Shifted Register) 24 P - Pre/Post (0=post; add offset after transfer, 1=pre; before trans.) 23 U - Up/Down Bit (0=down; subtract offset from base, 1=up; add to base) 22 B - Byte/Word bit (0=transfer word quantity, 1=transfer byte quantity) When above Bit 24 P=0 (Post-indexing, write-back is ALWAYS enabled): 21 T - Memory Managment (0=Normal, 1=Force non-privileged access) When above Bit 24 P=1 (Pre-indexing, write-back is optional): 21 W - Write-back bit (0=no write-back, 1=write address into base) 20 L - Load/Store bit (0=Store to memory, 1=Load from memory) 0: STR{cond}{B}{T} Rd,<Address> ;[Rn+/-<offset>]=Rd 1: LDR{cond}{B}{T} Rd,<Address> ;Rd=[Rn+/-<offset>] Whereas, B=Byte, T=Force User Mode (only for POST-Indexing) 19-16 Rn - Base register (R0..R15) (including R15=PC+8) 15-12 Rd - Source/Destination Register (R0..R15) (including R15=PC+12) When above I=0 (Immediate as Offset) 11-0 Unsigned 12bit Immediate Offset (0-4095, steps of 1) When above I=1 (Register shifted by Immediate as Offset) 11-7 Is - Shift amount (1-31, 0=Special/See below) 6-5 Shift Type (0=LSL, 1=LSR, 2=ASR, 3=ROR) 4 Must be 0 (Reserved, see ARM.17, The Undefined Instruction) 3-0 Rm - Offset Register (R0..R14) (not including PC=R15) |
<expression> ;an immediate used as address ;*** restriction: must be located in range PC+/-4095+8, if so, ;*** assembler will calculate offset and use PC (R15) as base. |
[Rn] ;offset = zero [Rn, <#{+/-}expression>]{!} ;offset = immediate [Rn, {+/-}Rm{,<shift>} ]{!} ;offset = register shifted by immediate |
[Rn], <#{+/-}expression> ;offset = immediate [Rn], {+/-}Rm{,<shift>} ;offset = register shifted by immediate |
<shift> immediate shift such like LSL#4, ROR#2, etc. (see ARM.5). {!} exclamation mark ("!") indicates write-back (Rn will be updated). |
ARM.10: Halfword and Signed Data Transfer (STRH,LDRH,LDRSB,LDRSH) |
Bit Expl. 31-28 Condition 27-25 Must be 000b for this instruction 24 P - Pre/Post (0=post; add offset after transfer, 1=pre; before trans.) 23 U - Up/Down Bit (0=down; subtract offset from base, 1=up; add to base) 22 I - Immediate Offset Flag (0=Register Offset, 1=Immediate Offset) When above Bit 24 P=0 (Post-indexing, write-back is ALWAYS enabled): 21 Not used, must be zero (0) When above Bit 24 P=1 (Pre-indexing, write-back is optional): 21 W - Write-back bit (0=no write-back, 1=write address into base) 20 L - Load/Store bit (0=Store to memory, 1=Load from memory) 19-16 Rn - Base register (R0-R15) (Including R15=PC+8) 15-12 Rd - Source/Destination Register (R0-R15) (Including R15=PC+12) 11-8 When above Bit 22 I=0 (Register as Offset): Not used. Must be 0000b When above Bit 22 I=1 (immediate as Offset): Immediate Offset (upper 4bits) 7 Reserved, must be set (1) 6-5 Opcode (0-3) When Bit 20 L=0 (Store): 0: Reserved for SWP instruction (see ARM.12 Single Data Swap) 1: STR{cond}H Rd,<Address> ;Store halfword 2: Reserved. 3: Reserved. When Bit 20 L=1 (Load): 0: Reserved. 1: LDR{cond}H Rd,<Address> ;Load Unsigned halfword (zero-extended) 2: LDR{cond}SB Rd,<Address> ;Load Signed byte (sign extended) 3: LDR{cond}SH Rd,<Address> ;Load Signed halfword (sign extended) 4 Reserved, must be set (1) 3-0 When above Bit 22 I=0: Rm - Offset Register (R0-R14) (not including R15) When above Bit 22 I=1: Immediate Offset (lower 4bits) (0-255, together with upper bits) |
<expression> ;an immediate used as address ;*** restriction: must be located in range PC+/-255+8, if so, ;*** assembler will calculate offset and use PC (R15) as base. |
[Rn] ;offset = zero [Rn, <#{+/-}expression>]{!} ;offset = immediate [Rn, {+/-}Rm]{!} ;offset = register |
[Rn], <#{+/-}expression> ;offset = immediate [Rn], {+/-}Rm ;offset = register |
{!} exclamation mark ("!") indicates write-back (Rn will be updated). |
ARM.11: Block Data Transfer (LDM,STM) |
Bit Expl. 31-28 Condition 27-25 Must be 100b for this instruction 24 P - Pre/Post (0=post; add offset after transfer, 1=pre; before trans.) 23 U - Up/Down Bit (0=down; subtract offset from base, 1=up; add to base) 22 S - PSR & force user bit (0=No, 1=load PSR or force user mode) 21 W - Write-back bit (0=no write-back, 1=write address into base) 20 L - Load/Store bit (0=Store to memory, 1=Load from memory) 0: STM{cond}{amod} Rn{!},<Rlist>{^} ;Store (Push) 1: LDM{cond}{amod} Rn{!},<Rlist>{^} ;Load (Pop) Whereas, {!}=Write-Back (W), and {^}=PSR/User Mode (S) 19-16 Rn - Base register (R0-R14) (not including R15) 15-0 Rlist - Register List (Above 'offset' is meant to be the number of words specified in Rlist.) |
IB increment before ;P=1, U=1 IA increment after ;P=0, U=1 DB decrement before ;P=1, U=0 DA decrement after ;P=0, U=0 |
ED empty stack, descending ;LDM: P=1, U=1 ;STM: P=0, U=0 FD full stack, descending ; P=0, U=1 ; P=1, U=0 EA empty stack, ascending ; P=1, U=0 ; P=0, U=1 FA full stack, ascending ; P=0, U=0 ; P=1, U=1 |
STMFD=STMDB=PUSH STMED=STMDA STMFA=STMIB STMEA=STMIA LDMFD=LDMIA=POP LDMED=LDMIB LDMFA=LDMDA LDMEA=LDMDB |
PUSH/POP: full descending ;base register SP (R13) LDM/STM: increment after ;base register R0..R7 |
While R15 loaded, additionally: CPSR=SPSR_<current mode> |
Rlist is referring to User Bank Registers, R0-R15 (rather than register related to the current mode, such like R14_svc etc.) Base write-back should not be used for User bank transfer. ! When instruction is LDM: ! ! If the following instruction reads from a banked register, ! ! like R14_svc, then CPU might still read R14 instead. If ! ! necessary insert a dummy instruction such like MOV R0,R0. ! |
ARM.12: Single Data Swap (SWP) |
Bit Expl. 31-28 Condition 27-23 Must be 00010b for this instruction Opcode (fixed) SWP{cond}{B} Rd,Rm,[Rn] ;Rd=[Rn], [Rn]=Rm 22 B - Byte/Word bit (0=swap word quantity, 1=swap byte quantity) 21-20 Must be 00b for this instruction 19-16 Rn - Base register (R0-R14) 15-12 Rd - Destination Register (R0-R14) 11-4 Must be 00001001b for this instruction 3-0 Rm - Source Register (R0-R14) |
ARM.13: Software Interrupt (SWI) |
Bit Expl. 31-28 Condition 27-24 Must be 1111b for this instruction Opcode (fixed) SWI{cond} nn 23-0 nn - Comment Field, ignored by processor (24bit value) |
R14_svc=PC+4 ;save return address SPSR_svc=CPSR ;save CPSR flags CPSR=<changed> ;Enter Supervisor mode (svc) in ARM state PC=00000008h ;jump to SWI vector address |
MOVS PC,R14 |
ARM.14: Coprocessor Data Operations (CDP) |
Bit Expl. 31-28 Condition 27-24 Must be 1110b for this instruction ARM-Opcode (fixed) CDP{cond} p#,<cpopc>,cd,cn,cm{,<cp>} 23-20 CP Opc - Coprocessor operation code (0-15) 19-16 CRn - Coprocessor operand Register (CR0-CR15) 15-12 CRd - Coprocessor destination Register (CR0-CR15) 11-8 CP# - Coprocessor number (0-15) 7-5 CP - Coprocessor information (0-7) 4 Reserved, must be zero 3-0 CRm - Coprocessor operand Register (CR0-CR15) |
ARM.15: Coprocessor Data Transfers (LDC,STC) |
Bit Expl. 31-28 Condition 27-25 Must be 110b for this instruction 24 P - Pre/Post (0=post; add offset after transfer, 1=pre; before trans.) 23 U - Up/Down Bit (0=down; subtract offset from base, 1=up; add to base) 22 N - Transfer length (0-1, interpretation depends on co-processor) 21 W - Write-back bit (0=no write-back, 1=write address into base) 20 Opcode (0-1) 0: STC{cond}{L} p#,cd,<Address> ;Store to memory (from coprocessor) 1: LDC{cond}{L} p#,cd,<Address> ;Read from memory (to coprocessor) whereas {L} indicates long transfer (Bit 22: N=1) 19-16 Rn - ARM Base Register (R0-R15) (R15=PC+8) 15-12 CRd - Coprocessor src/dest Register (CR0-CR15) 11-8 CP# - Coprocessor number (0-15) 7-0 Offset - Unsigned Immediate, step 4 (0-1020, in steps of 4) |
ARM.16: Coprocessor Register Transfers (MRC, MCR) |
Bit Expl. 31-28 Condition 27-24 Must be 1110b for this instruction 23-21 CP Opc - Coprocessor operation mode (0-7) 20 ARM-Opcode (0-1) 0: MCR{cond} p#,<cpopc>,Rd,cn,cm{,<cp>} ;move from ARM to CoPro 1: MRC{cond} p#,<cpopc>,Rd,cn,cm{,<cp>} ;move from CoPro to ARM 19-16 CRn - Coprocessor source/dest. Register (CR0-CR15) 15-12 Rd - ARM source/destination Register (R0-R15) 11-8 CP# - Coprocessor number (0-15) 7-5 CP - Coprocessor information (0-7) 4 Reserved, must be one (1) 3-0 CRm - Coprocessor operand Register (CR0-CR15) |
ARM.17: Undefined Instruction |
Bit Expl. 31-28 Condition 27-25 Must be 011b for this instruction 24-5 Reserved for future use 4 Must be 1b for this instruction 3-0 Reserved for future use |
Pseudo Instructions and Directives |
nop mov r0,r0 ldr Rd,=Imm ldr Rd,[r15,disp] ;use .pool as parameter field) add Rd,=addr add/sub Rd,r15,disp adr Rd,addr add/sub Rd,r15,disp adrl Rd,addr two add/sub opcodes with disp=xx00h+00yyh mov Rd,Imm mvn Rd,NOT Imm ;or vice-versa and Rd,Rn,Imm bic Rd,Rn,NOT Imm ;or vice-versa cmp Rd,Rn,Imm cmn Rd,Rn,-Imm ;or vice-versa add Rd,Rn,Imm sub Rd,Rn,-Imm ;or vice-versa |
nop mov r8,r8 ldr Rd,=Imm ldr Rd,[r15,disp] ;use .pool as parameter field add Rd,=addr add Rd,r15,disp adr Rd,addr add Rd,r15,disp mov Rd,Rs add Rd,Rs,0 ;with Rd,Rs in range r0-r7 each |
org adr assume following code from this address on .gba indicate GBA program .fix fix GBA header checksum .norewrite do not delete existing output file (keep following data in file) .data? following defines RAM data structure (assembled to nowhere) .code following is normal ROM code/data (assembled to ROM image) .include includes specified source code file (no nesting/error handling) .import imports specified binary file (optional parameters: ,begin,len) .if expr assembles following code only if expression is nonzero .else invert previous .if condition .endif terminate .if .ifdef sym assemble following only if symbol is defined .ifndef sym assemble following only if symbol is not defined .align nn aligns to an address divedable-by-nn, inserts 00's .msg defines a no$gba debugmessage string, such like .msg 'Init Okay' .brk defines a no$gba source code break opcode l equ n l=n l: [cmd] l=$ (global label) @@l: [cmd] @@l=$ (local label, all locals are reset at next global label) end end of source code db ... define 8bit data (bytes) dw ... define 16bit data (halfwords) dd ... define 32bit data (words) defs nn define nn bytes space (zero-filled) ;... defines a comment (ignored by the assembler) // alias for CRLF, eg. allows <db 'Text',0 // dw addr> in one line |
align .align 4 code16 .thumb align nn .align nn .code 16 .thumb % nn defs nn code32 .arm .space nn defs nn .code 32 .arm ..ds nn defs nn ltorg .pool x=n x equ n .ltorg .pool .equ x,n x equ n ..ltorg .pool .define x n x equ n dcb db (8bit data) incbin .import defb db (8bit data) @@@... ;comment .byte db (8bit data) @ ... ;comment .ascii db (8bit string) @*... ;comment dcw dw (16bit data) @... ;comment defw dw (16bit data) .text .code .hword dw (16bit data) .bss .data? dcd dd (32bit data) .global (ignored) defd dd (32bit data) .extern (ignored) .long dd (32bit data) .thumb_func (ignored) .word dw/dd, don't use #directive .directive .end end .fill nn,1,0 defs nn |
hs cs ;condition higher or same = carry set asl lsl ;arithmetic shift left = logical shift left |
Type Normal Alias Decimal 85 #85 Hexadecimal 55h #55h 0x55 #0x55 $55 Ascii 'U' "U" Binary 01010101b %01010101 |
mov r0,0ffh ;no C64-style "#", and no C-style "0x" required stmia [r7]!,r0,r4-r5 ;square [base] brackets, no fancy {rlist} brackets mov r0,cpsr ;no confusing MSR and MRS (whatever which is which) ldr r0,[score] ;allows to use clean brackets for relative addresses push rlist ;alias for stmfd [r13]!,rlist (and same for pop/ldmfd) label: ;label definitions recommended to use ":" colons |
CPU Instruction Cycle Times |
Instruction Cycles Additional --------------------------------------------------------------------- Data Processing 1S +1S+1N if R15 loaded, +1I if SHIFT(Rs) MSR,MRS 1S LDR 1S+1N+1I +1S+1N if R15 loaded STR 2N LDM nS+1N+1I +1S+1N if R15 loaded STM (n-1)S+2N SWP 1S+2N+1I BL (THUMB) 3S+1N B,BL 2S+1N SWI,trap 2S+1N MUL 1S+ml MLA 1S+(m+1)I MULL 1S+(m+1)I MLAL 1S+(m+2)I CDP 1S+bI LDC,STC (n-1)S+2N+bI MCR 1N+bI+1C MRC 1S+(b+1)I+1C {cond} false 1S |
n = number of words transferred b = number of cycles spent in coprocessor busy-wait loop m = depends on most significant byte(s) of multiplier operand |
CPU Data Sheet |
Pins of the original CPU, probably other for GBA. |
Optional virtual memory circuits, etc. not for GBA. |
As far as I know, none such in GBA. |
For external hardware-based debugging. |
For external hardware-based debugging also. |
Detailed: What happens during each cycle of each instruction. |
http://www.arm.com/Documentation/UserMans/PDF/ARM7TDMI.html |
About this Document |