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.

DS development > Resetting my homebrew

#122075 - FRuMMaGe - Fri Mar 16, 2007 9:54 pm

Is there a function that I could use to reset my homebrew program?

#122085 - Lick - Fri Mar 16, 2007 11:03 pm

On both processors:

Code:
asm("swi 0x00");
asm("bx lr");

_________________
http://licklick.wordpress.com

#122094 - FRuMMaGe - Fri Mar 16, 2007 11:35 pm

Lick wrote:
On both processors:

Code:
asm("swi 0x00");
asm("bx lr");


Thanks! What does this actually do though? I presume 0x00 is the null value?

#122098 - Lick - Sat Mar 17, 2007 12:37 am

http://lickr.org/gbatek.htm#biosresetfunctions!
_________________
http://licklick.wordpress.com

#122374 - FRuMMaGe - Mon Mar 19, 2007 12:06 am

Lick wrote:
On both processors:

Code:
asm("swi 0x00");
asm("bx lr");


Does resetting in this manner clear the variables?

#122385 - tepples - Mon Mar 19, 2007 3:25 am

It clears variables in ".bss", as resetting in such a manner runs the crt0 code that ordinarily runs before main(). But I don't think it sets variables in ".data" to their initial values.

In fact, GNU coding standards deprecate the use of ".data", preferring ".rodata" that gets copied into ".bss" by main():
Quote:
When static storage is to be written in during program execution, use explicit C code to initialize it. Reserve C initialized declarations for data that will not be changed.

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.