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 > ASM Return values....

#16436 - corranga - Mon Feb 16, 2004 2:05 pm

Ok, i've written some asm to do fixed point division, but whgen I got to the last line, I thought hang on, how does the asm retuurn a value?

The code is as follows:

fixedDivASM:
mov r3, r1
swi 0x60000
@answer is in r0
mov r12, r0, lsl #12
@remainder is in r1
mov r0, r1
mov r1, r3, lsl #12
swi 0x60000
orr r0, r1, r12

Providing the code works properly (I thnik it should) I end up with the answer in r0. How do I either:
Return r0
OR
Return the answer in another way?

Chris
_________________
If virtual reality is ever on a par with reality, I want to be Bomberman! :D

#16437 - corranga - Mon Feb 16, 2004 3:03 pm

umm, yeah I think i've solved it myself using

bx lr

now all I need is some form of font engine that can print out variables so I can check my answers :D

Chris
_________________
If virtual reality is ever on a par with reality, I want to be Bomberman! :D

#16438 - DekuTree64 - Mon Feb 16, 2004 4:03 pm

An easier way to check things than setting up a font engine is to set a specific place in memory to your answer and then check it in VBA's memory viewer. Can't use it on hardware, but it works great for debugging in VBA. I ususally just use somewhere out in the middle of EWRAM, like 0x2020000 that probably won't be getting used anyway.

And yes, just put your return value in r0 and bx lr to return in ASM.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#16818 - Lupin - Wed Feb 25, 2004 3:32 pm

you can also use the VBA console... but writing a font engine isn't that hard :)