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 > Some ASM

#24107 - ProblemBaby - Wed Jul 28, 2004 2:08 am

Iam trying and trying to add some asm code into my
project and Ive two big problems.

1.
Ive added added some BIOS-calls the one ive tried works except for one!
VBlankIntrWait.

Code (yes it is a lot C but I dont think that is the problem):
Code:

void VBlankIntrWait();

void VBlankInt()
{
   REG_IF |= 0x1;
}

void AgbMain()
{
   IntrTable[0] = VBlankInt;
   REG_DISPSTAT = 0x8;
   REG_IE |= 0x1;
   REG_IME = 1;
   

   while (1)
   {
      // Do stuff
      VBlankIntrWait();
   }
}

// then in a .S file
.arm
.align 4
.section .iwram

.global VBlankIntrWait
VBlankIntrWait:
   SWI 0x050000
   BX lr

Can someone see an error?

2.
Ive made thumb_func-functions they worked until a tried to do
one function that is anything special. But VBA tell me this:
Unsupported BIOS function 9f called from 02017490. A BIOS file is needed in order to get correct behaviour.
The interesting thing is if Ive a function like:
Code:

.thumb_func
.global func:
func
bx lr

this one works.
but if I put one intruction more onto it i got the error.
even if I do this:
Code:

.thumb_func
.global func:
func
bx lr
bx lr

and this works if I take away the other function that is in the file
except the head and bx lr.
strange huh!!

#24118 - dagamer34 - Wed Jul 28, 2004 4:03 am

Man, I think this should be FAQed. I had this problem to but luckily I solved it today by reading some old posts. You have to notify the bios that a vblank has occured. Here's the code:

Put this where you define a whole bunch of registers, I like to put it right under REG_INTERUPT.
Code:

#define REG_BIOSVBLANK     *(vu16*)0x3007ff8      /* BIOS VBLANK Interrupt status bit*/


And then change your VBlank code to this:
Code:

void VBlankInt()
{
   // Acknowledge to the BIOS that a Vblank interupt has occured
   REG_BIOSVBLANK = 1;
   REG_IF |= 0x1;
}


I don't think I can solve your other problem, maybe someone more experienced in assembly can.
_________________
Little kids and Playstation 2's don't mix. :(

#24125 - DekuTree64 - Wed Jul 28, 2004 7:49 am

Yup, that problem should definitely go into the FAQ. I had a hard battle with it myself when I first tried to use the VBlank SWI. Would you mind adding it, Tepples?

Not sure what's happening in that other problem though. You are using GCC and not Goldroad or anything, right? If so, that shouldn't even compile, with the colon after the .global, and the label by itself. Or maybe you just typed it into the message by hand and made a typo. In any case, I need to see more code to figure out what's wrong.
Simple things to try that probably won't fix it:
1. Put .align 2 before it
2. Put .thumb before it (I think .thumb_func automatically switches to reading instructions as thumb, but you never know)
3. Make it a little longer so you have more to compare with, use the -Map file.map option when linking to check where the function is, and then go look at it in VBA's disassembly to see if it looks the same

And that's all I can think of for now, because I'm sleepy.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#24137 - ProblemBaby - Wed Jul 28, 2004 12:09 pm

1.
Thanks,
it works in VBA but not at hardware any idea?
just one more question as you saw in my first post the functions is put in iwram and that works perfect when i compile as multiboot but if I dont it doesn't work (ive to choose rodata).
Something I should know???

2.
Yeah it was a typo, I should look at it more today and see if I can solve if thanks for the tips. I'll post more code if I can't

#24146 - tepples - Wed Jul 28, 2004 3:21 pm

Things related to the BIOS may in fact work differently on the GBA and VBA. That said, I'm working on wording it for the FAQ.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#24460 - ProblemBaby - Wed Aug 04, 2004 1:18 am

I got strange, strange problems I dont understand!

Code:

.thumb
.align
.section .rodata
.thumb_func

.global IntrWait
IntrWait:
   SWI 0x04
   BX lr

// .. more BIOS functions

HuffUnComp:
   @SWI 0x13
   
   hej:
   LDR r2, =0x4000000
   LDR r3, =0x403
   
   B hej
   
   BX lr


this is my asm-file when I try to call HuffUnComp the code never come to this functions I dont understand why!
+ I got the strange VBA error (BIOS File)
why, why, why?? please help!
it worked when it was ARM code and in iwram in VBA but not at hardware
but I want it in ROM is that impossible??

#24544 - ProblemBaby - Thu Aug 05, 2004 3:37 pm

I fixed it it must be .text instead of .section .rodata
for code!