Tech Specs
|
If you want to learn ARM get the Cheatsheet! it has all the ARM7 commands, it covers the commands, and options like Bitshifts and conditions as well as the bytecode structure of the commands! |
Hello World on the Nintendo DS - ARM Assembly Lesson H3 |
Address | Purpose |
0x00000000 |
Instruction TCM (32KB) (not moveable) (mirror-able to 1000000h) |
0x00????000 | Data TCM (16KB) (moveable) |
0x02000000 | Main Memory (4MB) |
0x03000000 | Shared WRAM (0KB, 16KB, or 32KB can be allocated to ARM9) |
0x04000000 | ARM9-I/O Ports |
0x05000000 | Engine A Standard BG Palette (512 bytes) |
0x05000200 | Engine A Standard OBJ Palette (512 bytes) |
0x05000400 | Engine B Standard BG Palette (512 bytes) |
0x05000600 | Engine B Standard OBJ Palette (512 bytes) |
0x06000000 | VRAM - Engine A, BG VRAM (max 512KB) |
0x06200000 | VRAM - Engine B, BG VRAM (max 128KB) |
0x06400000 | VRAM - Engine A, OBJ VRAM (max 256KB) |
0x06600000 | VRAM - Engine B, OBJ VRAM (max 128KB) |
0x06800000 | VRAM - "LCDC"-allocated (max 656KB) |
0x07000000 | Engine A OAM (1024 bytes) |
0x07000400
|
Engine B OAM (1024 bytes) |
0x08000000 | GBA Slot ROM (max 32MB) |
0x0A000000 | GBA Slot RAM (max 64KB) |
0xFFFF0000 | ARM9-BIOS (32KB) (only 3K used) |
Category | Address | Name | Description |
DispA | 0x4000000 | DISPCNT | LCD Control (RW) |
DispA | 0x4000004 | 2D Engine
A+B - DISPSTAT - General LCD Status (RW) (Bit 0=VBlank) |
|
DispA | 0x4000006 | 2D Engine A+B - VCOUNT - Vertical Counter (Read only) | |
DispA | 0x4000008 | 2D Engine A (same registers as GBA, some changed bits) | |
DispA | 0x4000008 | BG0CNT | BG0 Control |
DispA | 0x400000A | BG1CNT | BG1 Control |
DispA | 0x400000C | BG2CNT | BG2 Control |
DispA | 0x400000E | BG3CNT | BG3 Control |
DispA | 0x4000010 | BG0HOFS | BG0 X-Offset |
DispA | 0x4000012 | BG0VOFS | BG0 Y-Offset |
DispA | 0x4000014 | BG1HOFS | BG1 X-Offset |
DispA | 0x4000016 | BG1VOFS | BG1 Y-Offset |
DispA | 0x4000018 | BG2HOFS | BG2 X-Offset |
DispA | 0x400001A | BG2VOFS | BG2 Y-Offset |
DispA | 0x400001C | BG3HOFS | BG3 X-Offset |
DispA | 0x400001E | BG3VOFS | BG3 Y-Offset |
DispA | 0x4000020 | BG2PA | BG2 Rotation/Scaling Parameter A (dx) |
DispA | 0x4000022 | BG2PB | BG2 Rotation/Scaling Parameter B (dmx) |
DispA | 0x4000024 | BG2PC | BG2 Rotation/Scaling Parameter C (dy) |
DispA | 0x4000026 | BG2PD | BG2 Rotation/Scaling Parameter D (dmy) |
DispA | 0x4000028 | BG2X | BG2 Reference Point X-Coordinate |
DispA | 0x400002C | BG2Y | BG2 Reference Point Y-Coordinate |
DispA | 0x4000030 | BG3PA | BG3 Rotation/Scaling Parameter A (dx) |
DispA | 0x4000032 | BG3PB | BG3 Rotation/Scaling Parameter B (dmx) |
DispA | 0x4000034 | BG3PC | BG3 Rotation/Scaling Parameter C (dy) |
DispA | 0x4000036 | BG3PD | BG3 Rotation/Scaling Parameter D (dmy) |
DispA | 0x4000038 | BG3X | BG3 Reference Point X-Coordinate |
DispA | 0x400003C | BG3Y | BG3 Reference Point Y-Coordinate |
DispA | 0x4000040 | WIN0H | Window 0 Horizontal Dimensions |
DispA | 0x4000042 | WIN1H | Window 1 Horizontal Dimensions |
DispA | 0x4000044 | WIN0V | Window 0 Vertical Dimensions |
DispA | 0x4000046 | WIN1V | Window 1 Vertical Dimensions |
DispA | 0x4000048 | WININ | Inside of Window 0 and 1 |
DispA | 0x400004A | WINOUT | Inside of OBJ Window & Outside of Windows |
DispA | 0x400004C | MOSAIC | Mosaic Size |
DispA | 0x400004E | - | Not used |
DispA | 0x4000050 | BLDCNT | Color Special Effects Selection |
DispA | 0x4000052 | BLDALPHA | Alpha Blending Coefficients |
DispA | 0x4000054 | BLDY | Brightness (Fade-In/Out) Coefficient |
DispA | 0x4000056 | - | Not used |
DispA | 0x4000060 | DISP3DCNT - 3D Display Control Register (R/W) | |
DispA | 0x4000064 | DISPCAPCNT - Display Capture Control Register (R/W) | |
DispA | 0x4000068 | DISP_MMEM_FIFO - Main Memory Display FIFO (R?/W) | |
DispA | 0x400006C | 2D Engine A - MASTER_BRIGHT - Master Brightness Up/Down | |
DMA/Key | 0x40000B0 | DMA Channel 0..3 | |
DMA/Key | 0x40000E0 | DMA FILL Registers for Channel 0..3 | |
DMA/Key | 0x4000100 | Timers 0..3 | |
DMA/Key | 0x4000130 | KEYINPUT
(Gameboy Advance Type Keys UDLR AB Sel Start) |
|
DMA/Key | 0x4000132 | KEYCNT | |
IPC/Rom | 0x4000180 | IPCSYNC - IPC Synchronize Register (R/W) | |
IPC/Rom | 0x4000184 | IPCFIFOCNT - IPC Fifo Control Register (R/W) | |
IPC/Rom | 0x4000188 | IPCFIFOSEND - IPC Send Fifo (W) | |
IPC/Rom | 0x40001A0 | AUXSPICNT - Gamecard ROM and SPI Control | |
IPC/Rom | 0x40001A2 | AUXSPIDATA - Gamecard SPI Bus Data/Strobe | |
IPC/Rom | 0x40001A4 | Gamecard bus timing/control | |
IPC/Rom | 0x40001A8 | Gamecard bus 8-byte command out | |
IPC/Rom | 0x40001B0 | Gamecard Encryption Seed 0 Lower 32bit | |
IPC/Rom | 0x40001B4 | Gamecard Encryption Seed 1 Lower 32bit | |
IPC/Rom | 0x40001B8 | Gamecard Encryption Seed 0 Upper 7bit (bit7-15 unused) | |
IPC/Rom | 0x40001BA | Gamecard Encryption Seed 1 Upper 7bit (bit7-15 unused) | |
Ram/IRQ | 0x4000204 | EXMEMCNT - External Memory Control (R/W) | |
Ram/IRQ | 0x4000208 | IME - Interrupt Master Enable (R/W) | |
Ram/IRQ | 0x4000210 | IE | |
Ram/IRQ | 0x4000214 | IF | |
Ram/IRQ | 0x4000240 | VRAMCNT_A - VRAM-A (128K) Bank Control (W) | |
Ram/IRQ | 0x4000241 | VRAMCNT_B - VRAM-B (128K) Bank Control (W) | |
Ram/IRQ | 0x4000242 | VRAMCNT_C - VRAM-C (128K) Bank Control (W) | |
Ram/IRQ | 0x4000243 | VRAMCNT_D - VRAM-D (128K) Bank Control (W) | |
Ram/IRQ | 0x4000244 | VRAMCNT_E - VRAM-E (64K) Bank Control (W) | |
Ram/IRQ | 0x4000245 | VRAMCNT_F - VRAM-F (16K) Bank Control (W) | |
Ram/IRQ | 0x4000246 | VRAMCNT_G - VRAM-G (16K) Bank Control (W) | |
Ram/IRQ | 0x4000247 | WRAMCNT | |
Ram/IRQ | 0x4000248 | VRAMCNT_H - VRAM-H (32K) Bank Control (W) | |
Ram/IRQ | 0x4000249 | VRAMCNT_I - VRAM-I (16K) Bank Control (W) | |
Maths | 0x4000280 | DIVCNT - Division Control (R/W) | |
Maths | 0x4000290 | DIV_NUMER - Division Numerator (R/W) | |
Maths | 0x4000298 | DIV_DENOM - Division Denominator (R/W) | |
Maths | 0x40002A0 | DIV_RESULT - Division Quotient (=Numer/Denom) (R) | |
Maths | 0x40002A8 | DIVREM_RESULT - Division Remainder (=Numer MOD Denom) (R) | |
Maths | 0x40002B0 | SQRTCNT - Square Root Control (R/W) | |
Maths | 0x40002B4 | SQRT_RESULT - Square Root Result (R) | |
Maths | 0x40002B8 | SQRT_PARAM - Square Root Parameter Input (R/W) | |
Maths | 0x4000300 | POSTFLG - Undoc | |
Maths | 0x4000304 | POWCNT1 - Graphics Power Control Register (R/W) | |
Disp3D | 0x4000320..6A3 | ||
2D Engine B | 0x4001000 | DISPCNT | LCD Control (RW) |
2D Engine B | 0x4001008 | (same registers as GBA, some changed bits) | |
2D Engine B | 0x4001008 | BG0CNT | BG0 Control |
2D Engine B | 0x400100A | BG1CNT | BG1 Control |
2D Engine B | 0x400100C | BG2CNT | BG2 Control |
2D Engine B | 0x400100E | BG3CNT | BG3 Control |
2D Engine B | 0x4001010 | BG0HOFS | BG0 X-Offset |
2D Engine B | 0x4001012 | BG0VOFS | BG0 Y-Offset |
2D Engine B | 0x4001014 | BG1HOFS | BG1 X-Offset |
2D Engine B | 0x4001016 | BG1VOFS | BG1 Y-Offset |
2D Engine B | 0x4001018 | BG2HOFS | BG2 X-Offset |
2D Engine B | 0x400101A | BG2VOFS | BG2 Y-Offset |
2D Engine B | 0x400101C | BG3HOFS | BG3 X-Offset |
2D Engine B | 0x400101E | BG3VOFS | BG3 Y-Offset |
2D Engine B | 0x4001020 | BG2PA | BG2 Rotation/Scaling Parameter A (dx) |
2D Engine B | 0x4001022 | BG2PB | BG2 Rotation/Scaling Parameter B (dmx) |
2D Engine B | 0x4001024 | BG2PC | BG2 Rotation/Scaling Parameter C (dy) |
2D Engine B | 0x4001026 | BG2PD | BG2 Rotation/Scaling Parameter D (dmy) |
2D Engine B | 0x4001028 | BG2X | BG2 Reference Point X-Coordinate |
2D Engine B | 0x400102C | BG2Y | BG2 Reference Point Y-Coordinate |
2D Engine B | 0x4001030 | BG3PA | BG3 Rotation/Scaling Parameter A (dx) |
2D Engine B | 0x4001032 | BG3PB | BG3 Rotation/Scaling Parameter B (dmx) |
2D Engine B | 0x4001034 | BG3PC | BG3 Rotation/Scaling Parameter C (dy) |
2D Engine B | 0x4001036 | BG3PD | BG3 Rotation/Scaling Parameter D (dmy) |
2D Engine B | 0x4001038 | BG3X | BG3 Reference Point X-Coordinate |
2D Engine B | 0x400103C | BG3Y | BG3 Reference Point Y-Coordinate |
2D Engine B | 0x4001040 | WIN0H | Window 0 Horizontal Dimensions |
2D Engine B | 0x4001042 | WIN1H | Window 1 Horizontal Dimensions |
2D Engine B | 0x4001044 | WIN0V | Window 0 Vertical Dimensions |
2D Engine B | 0x4001046 | WIN1V | Window 1 Vertical Dimensions |
2D Engine B | 0x4001048 | WININ | Inside of Window 0 and 1 |
2D Engine B | 0x400104A | WINOUT | Inside of OBJ Window & Outside of Windows |
2D Engine B | 0x400104C | MOSAIC | Mosaic Size |
2D Engine B | 0x400104E | - | Not used |
2D Engine B | 0x4001050 | BLDCNT | Color Special Effects Selection |
2D Engine B | 0x4001052 | BLDALPHA | Alpha Blending Coefficients |
2D Engine B | 0x4001054 | BLDY | Brightness (Fade-In/Out) Coefficient |
2D Engine B | 0x4001056 | - | Not used |
2D Engine B | 0x400106C | MASTER_BRIGHT | 16bit - Brightness Up/Down |
DSI | 0x40021Ax | DSi Registers | |
DSI | 0x4004xxx | DSi Registers | |
IPC/Rom | 0x4100000 | IPCFIFORECV - IPC Receive Fifo (R) | |
IPC/Rom | 0x4100010 | Gamecard bus 4-byte data in, for manual or dma read | |
Debug | 0x4FFF0xx | Ensata Emulator Debug Registers | |
Debug | 0x4FFFAxx | No$gba Emulator Debug Registers | |
Exception | 0x27FFD9C | NDS9 Debug Stacktop / Debug Vector (0=None) | |
Exception | DTCM+3FF8 4 | ||
Exception | DTCM+3FFC 4 | ||
RamCtrl | 0x27FFFFE | Main Memory Control |
Offset |
Bytes |
Purpose | Notes | Sample |
000h | 12 | Game Title | (Uppercase ASCII, padded with 00h) | .ascii "LEARNASM.NET" |
00Ch | 4 | Gamecode | (Uppercase ASCII, NTR-<code>)(0=homebrew) | .ascii "0000" |
010h | 2 | Makercode | (Uppercase ASCII, eg. "01"=Nintendo) (0=homebrew) | .ascii "00" |
012h | 1 | Unitcode | (00h=NDS, 02h=NDS+DSi, 03h=DSi) (bit1=DSi) | .byte 0x00 |
013h | 1 | Encryption Seed Select | (00..07h, usually 00h) | .byte 0x00 |
014h | 1 | Devicecapacity | (Chipsize = 128KB SHL nn) (eg. 7 = 16MB) | .byte 0x00 |
015h | 7 | Reserved | (zero filled) | .space 7 |
01Ch | 1 | Reserved | (zero)(except, used on DSi) | .byte 0 |
01Dh | 1 | NDS Region | (00h=Normal, 80h=China, 40h=Korea) (other on DSi) | .byte 0 |
01Eh | 1 | ROM Version | (usually 00h) | .byte 0 |
01Fh | 1 | Autostart | (Bit2: Skip "Press Button" after Health and Safety) | .byte 4 |
020h | 4 | ARM9 rom_offset | (0x4000h and up, align 1000h) | .long Arm9_Start-HeaderStart |
024h | 4 | ARM9 entry_address | (2000000h..23BFE00h) | .long 0x02000000 |
028h | 4 | ARM9 ram_address | (2000000h..23BFE00h) | .long 0x02000000 |
02Ch | 4 | ARM9 size | (max 3BFE00h) (3839.5KB) | .long Arm9_End-Arm9_Start |
030h | 4 | ARM7 rom_offset | (8000h and up) | .long Arm7_Start-HeaderStart |
034h | 4 | ARM7 entry_address | (2000000h..23BFE00h, or 37F8000h..3807E00h) | .long 0x03800000 |
038h | 4 | ARM7 ram_address | (2000000h..23BFE00h, or 37F8000h..3807E00h) | .long 0x03800000 |
03Ch | 4 | ARM7 size | (max 3BFE00h, or FE00h) (3839.5KB, 63.5KB) | .long Arm7_End-Arm7_Start |
040h | 4 | File Name Table (FNT) offset | .long 0 | |
044h | 4 | File Name Table (FNT) size | .long 0 | |
048h | 4 | File Allocation Table (FAT) offset | .long 0 | |
04Ch | 4 | File Allocation Table (FAT) size | .long 0 | |
050h | 4 | File ARM9 overlay_offset | .long 0 | |
054h | 4 | File ARM9 overlay_size | .long 0 | |
058h | 4 | File ARM7 overlay_offset | .long 0 | |
05Ch | 4 | File ARM7 overlay_size | .long 0 | |
060h | 4 | Port 0x40001A4h setting for normal cmd | (usually 00586000h) | .long 0x00586000 |
064h | 4 | Port 0x40001A4h setting for KEY1 cmd | (usually 001808F8h) | .long 0x001808F8 |
068h | 4 | Icon/Title offset | (0=None) (8000h and up) | .long 0 |
06Ch | 2 | Secure Area Checksum | CRC-16 of [[020h]..00007FFFh] | .word 0 |
06Eh | 2 | Secure Area Delay (in 131kHz units) | (051Eh=10ms or 0D7Eh=26ms) | .word 0 |
070h | 4 | ARM9 Auto Load List Hook RAM Addr. | \endaddr of auto-load | .long 0 |
074h | 4 | ARM7 Auto Load List Hook RAM Addr. | /functions | .long 0 |
078h | 8 | Secure Area Disable | (by encrypted "NmMdOnly") (usually zero) | .space 8 |
080h | 4 | Total Used ROM size | (remaining/unused bytes usually FFh-padded) | .long 0 |
084h | 4 | ROM Header Size | (0x4000h) | .long 0x0x4000 |
088h | 28h | Reserved | (zero filled except, [88h..93h] used on DSi) | .space 0x28 |
0B0h | 10h | Reserved | (zero filled or "DoNotZeroFillMem"=unlaunch fastboot) | .space 0x10 |
0C0h | 9Ch | Nintendo Logo | (compressed bitmap, same as in GBA Headers) | .space 0x9C |
15Ch | 2 | Nintendo Logo Checksum | CRC-16 of [0C0h-15Bh], fixed CF56h | .word 0 |
15Eh | 2 | Header Checksum | CRC-16 of [000h-15Dh] | .word 0 |
160h | 4 | Debug rom_offset | (0=none) (8000h and up) only if debug | .long 0 |
164h | 4 | Debug size | (0=none) (max 3BFE00h) | .long 0 |
168h | 4 | Debug ram_address | (0=none) (20x400000h..27BFE00h) SIO and 8MB | .long 0 |
16Ch | 4 | Reserved | (zero filled) (transferred, and stored, but not used) | .long 0 |
170h | 90h | Reserved | (zero filled) (transferred, and stored, but not used) | .space 0x90 |
There is a working 'single asm' bare metal sample in the sources.7z |
Address | Bytes | Name | Description | Bits | Notes |
0x4000304h | 2 | POWCNT2 | Sound/Wifi Power Control Register (R/W) | ------WS | S=Sound on W=Wifi on |
0x40004x0h | 4 | SOUNDxCNT | Sound Channel X Control Register (R/W) | SFFRRWWW-PPPPPPPH-----DD-VVVVVVV | S=Start F=Format R=Repeat W=Wave duty P=Panning H=Hold D=volume Div V=Volume |
0x40004x4h | 4 | SOUNDxSAD | Sound Channel X Data Source Register (W) | -----AAAAAAAAAAAAAAAAAAAAAAAA00 | A=Address of sample |
0x40004x8h | 2 | SOUNDxTMR | Sound Channel X Timer Register (W) | FFFFFFFFFFFFFFFF | F=Frequency |
0x40004xAh | 2 | SOUNDxPNT | Sound Channel X Loopstart Register (W) | LLLLLLLLLLLLLLLL | L=Loop Start |
0x40004xCh | 4 | SOUNDxLEN | Sound Channel X Length Register (W) | ----------LLLLLLLLLLLLLLLLLLLLL | L=Length |
0x4000500h | 2 | SOUNDCNT | Sound Control Register (R/W) | M-31RRLL-VVVVVVV | M=Master on 31=output 31 to mixer RRLL=output from V=master Volume |
0x4000504h | 2 | SOUNDBIAS | Sound Bias Register (R/W) | -------BBBBBBBBBB | B=Sound Bias |
0x4000508h | 1 | SNDCAP0CNT | Sound Capture 0 Control Register (R/W) | S---FEsC | S=Start F=Format R=Repeat s=source C=Control |
0x4000509h | 1 | SNDCAP1CNT | Sound Capture 1 Control Register (R/W) | S---FEsC | |
0x4000510h | 4 | SNDCAP0DAD | Sound Capture 0 Destination Address (R/W) | -----AAAAAAAAAAAAAAAAAAAAAAAA00 | A=Address of Capture |
0x4000514h | 2 | SNDCAP0LEN | Sound Capture 0 Length (W) | LLLLLLLLLLLLLLLL | L=Length |
0x4000518h | 4 | SNDCAP1DAD | Sound Capture 1 Destination Address (R/W) | -----AAAAAAAAAAAAAAAAAAAAAAAA00 | |
0x400051Ch | 2 | SNDCAP1LEN | Sound Capture 1 Length (W) | LLLLLLLLLLLLLLLL | L=Length |
H Byte | L Byte | ||||||||||||||||
VRAM Address | F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | Details |
7000000h | S | S | C | M | T | T | D | R | Y | Y | Y | Y | Y | Y | Y | Y | Y=Ypos S=Shape (Square /HRect / Vrect)
C=Colors(16/256) M=Mosiac T=Transparent D=Disable/Doublesize R=Rotation |
7000002h | S | S | V | H | R | R | R | X | X | X | X | X | X | X | X | X | X=Xpos S=Obj Size (8x8,16x16,32x32,64x64)
VH=V/HFlip R=Rotation parameter |
7000004h | C | C | C | C | P | P | T | T | T | T | T | T | T | T | T | T | T=Tile Number C=Color palette (16 color mode) P=Priority |
7000006h | Unused by sprite |
On the GBA and NDS In some modes, Layers BG2 and
BG3 can be rotated and scaled. The control of this is performed
by registers 0x4001020h-0x400103Ch
For the mathematically challenged
(Like me) I've created a spreadsheet which helps calculate the
correct values for the effect you want... get it Here
|
NDS Example: |
Address | Function
|
Name | Bits | Default |
0x0x4001020 |
BG2PA | BG2 Rotation/Scaling Parameter A (dx) | SIIIIIIIFFFFFFFF | 0x0100 |
0x0x4001022 | BG2PB | BG2 Rotation/Scaling Parameter B (dmx) | SIIIIIIIFFFFFFFF | 0x0000 |
0x0x4001024 | BG2PC | BG2 Rotation/Scaling Parameter C (dy) | SIIIIIIIFFFFFFFF | 0x0000 |
0x0x4001026 | BG2PD | BG2 Rotation/Scaling Parameter D (dmy) | SIIIIIIIFFFFFFFF | 0x0100 |
0x0x4001028 | BG2X | BG2 Reference Point X-Coordinate | ----SIIIIIIIIIIIIIIIIIIIFFFFFFFF | 0x00000000 |
0x0x400102C | BG2Y | BG2 Reference Point Y-Coordinate | ----SIIIIIIIIIIIIIIIIIIIFFFFFFFF | 0x00000000 |
0x0x4001030 | BG3PA | BG3 Rotation/Scaling Parameter A (dx) | SIIIIIIIFFFFFFFF | 0x0100 |
0x0x4001032 | BG3PB | BG3 Rotation/Scaling Parameter B (dmx) | SIIIIIIIFFFFFFFF | 0x0000 |
0x0x4001034 | BG3PC | BG3 Rotation/Scaling Parameter C (dy) | SIIIIIIIFFFFFFFF | 0x0000 |
0x0x4001036 | BG3PD | BG3 Rotation/Scaling Parameter D (dmy) | SIIIIIIIFFFFFFFF | 0x0100 |
0x0x4001038 | BG3X | BG3 Reference Point X-Coordinate | ----SIIIIIIIIIIIIIIIIIIIFFFFFFFF | 0x00000000 |
0x0x400103C | BG3Y | BG3 Reference Point Y-Coordinate | ----SIIIIIIIIIIIIIIIIIIIFFFFFFFF | 0x00000000 |