gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > NDS Assembler questions

#166890 - cewlout - Sun Feb 22, 2009 11:44 pm

Hello dudes,

Is anyone able to point me to a nds assembly language example file with simple graphic display or something?

Or some kind of startup code for the nintendo ds? (Turning on LCD correctly etc..?)

Which compiler for assembly do you prefer for nds?

thanks a lot.

#166893 - Dwedit - Mon Feb 23, 2009 12:46 am

Use C combined with Assembly for the best of both worlds.
That way you can do low performance stuff in a less tedious programming language, then ASM for the high performance stuff.

To mix C and Assembly, preserve registers r4-r11 after calling ASM from C, like this:
Code:

my_asm_function:
  stmfd sp!,{r4-r11,lr}
  ...
  ldmfd sp!,{r4-r11,lr}
  bx lr

Registers r0-r3 are used as arguments, and r0 is for return values.
You'll probably want to call your ASM code from inside C code, even if it's just from within the main function.

You can use the GNU assembler from devkitarm, its only quirks are the confusing syntax for declaring a section of code to be in faster RAM, and that is uses @ as the comment character.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."