March 27, 2017, 07:34:49 AM*

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Advanced search  
Pages: [1]
Print
Author Topic: Compiling your first GBA asm binary  (Read 3857 times)
0 Members and 1 Guest are viewing this topic.
headkaze
Administrator
Blue Gene Super Computer
**********
Offline Offline

Gender: Male
Posts: 7754



« on: December 19, 2008, 11:05:22 PM »

1. If you haven't already followed the Setting up the compiler I suggest you do that first
2. Create a folder called devkitPro\source\gba\asmtest

Code:
.arm
.text
.global main
main:
mov r0, #0x4000000
mov r1, #0x400
add r1, r1, #3
str r1, [r0]

mov r0, #0x6000000
mov r1, #0xFF
mov r2, #0x9600
loop1:
strh r1, [r0], #2
subs r2, r2, #1
bne loop1

infin:
b infin

3. Run make
4. Open Visualboy Advanced emulator and open asmtest_mb.gba you should see the attached image
5. Congrats you have just created your first gba binary in assembly!

This code is from GBAGuy's GBA asm tutorial


* gbaasm.png (5.22 KB, 248x207 - viewed 493 times.)
* asmtest_gba.zip (9.96 KB - downloaded 187 times.)
« Last Edit: December 21, 2008, 06:58:06 PM by headkaze » Logged
headkaze
Administrator
Blue Gene Super Computer
**********
Offline Offline

Gender: Male
Posts: 7754



« Reply #1 on: December 21, 2008, 06:59:57 PM »

Next example we will display a picture on screen

Code:
.arm
.text
.global main
main:
mov r0, #0x4000000
mov r1, #0x400
add r1, r1, #3
str r1, [r0]

mov r0, #0x6000000
ldr r1,=picBitmap
mov r3, #0x4B00
loop:
ldr r2,[r1],#4
str r2,[r0],#4
subs r3,r3,#1
bne loop

infin:
b infin


* vba.png (43.03 KB, 248x207 - viewed 465 times.)
* showpic_gba.zip (231.37 KB - downloaded 195 times.)
Logged
headkaze
Administrator
Blue Gene Super Computer
**********
Offline Offline

Gender: Male
Posts: 7754



« Reply #2 on: December 21, 2008, 09:01:28 PM »

An example from GBAGuy's GBA asm tutorial is a simple demo to play sound

Code:
#include "sound.h"

.arm
.text
.global main

main:
    SoundOn                                                   @ Step 1: My macro that turns the sound circut on in REG_SOUNDCNT_X
                                                                   @ note no 'x' for sound channel number. REG_SOUNDCNT_X controls entire circut.

    S1_Enable                                                 @ Step 2: My macro to enable Sound Channel 1. S2_Enable is channel 2... to 4.

    ldr r1,=REG_SOUND1CNT_L                           @ in these two lines I do steps 3&4 at once. since these
    ldr r0,=0xf7800056                                     @ registers are 16bit, we can do both at once.
    str r0,[r1]                                                 @ store data for steps 3&4.

    ldr r1,=REG_SOUND1CNT_X                          @ Step 5: Load the register. 
    ldr r0,=0x8400   @ This register has something to do with choosing
    str r0,[r1]                                                 @ between the different stuff a channel can do such as Square wave or

loop:
    b loop

* sound_gba.zip (10.88 KB - downloaded 186 times.)
« Last Edit: December 21, 2008, 09:03:03 PM by headkaze » Logged
Pages: [1]
Print
Jump to: