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 and multiboot related problem...

#82910 - Natso - Thu May 11, 2006 3:19 am

<i moved this from the coding forum, I realized that this forum specializes in ASM>

Ok, I got the multiboot demo from this site... I was able to change the demo up some and keep it working good. I implimented it into my space game (www.gamesforfree.net/natso/sea/)(yes, the full game will end up easily within the limits of multiboot-dom) and have but a single problem now,

I get these errors when running my makefile:

c:\windows\TEMP/ccDVX3fb.s: Assembler messages:
c:\windows\TEMP/ccDVX3fb.s:524: Error: invalid offset, target not word aligned (
0x000078F2)
c:\windows\TEMP/ccDVX3fb.s:524: Error: invalid offset, value too big (0x000075BC
)
c:\windows\TEMP/ccDVX3fb.s:524: Error: cannot represent THUMB_OFFSET relocation
in this object file format


And also, the errors dissapear when I comment out this code. However this code is vital to making multiboot work, so its not something I want to keep commented ;)

asm volatile (
" ldr r0,=mp\n"
" mov r1,#1\n"
" swi 0x25\n"
::: "r0","r1","r2","r8","r9","r10","r11","r12"
);

(this came directly from the demo)


Any clues as to what I should do?
_________________
I'm a bomb technitian. If you see me running, try to keep up ;)

#82911 - tepples - Thu May 11, 2006 3:30 am

I tend to distrust the kludgy way GCC goes about supporting inline assembly language code. Have you tried making it a separate function in a separate assembly file? Put all this into swi25.s:
Code:

.THUMB
.THUMB_FUNC
.ALIGN
.GLOBL  swi25

swi25:
  swi 0x25
  bx lr


Then in your C code:
Code:

int swi25(void *r0, int r1);

int vitalFunction() {
  swi25(mp, 1);
}

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

#82948 - Natso - Thu May 11, 2006 12:37 pm

2 things:

1. I could never get your code to work
2. The errors I got from your code helped me to figure out to do with my original code & I just had to place it as one of the first two files and it started working perfect.

So... Thank You tepples!

- Zach
_________________
I'm a bomb technitian. If you see me running, try to keep up ;)

#83041 - gladius - Fri May 12, 2006 8:02 am

Tepples' solution should be fine. But in any case, if you happen to run into that error again it's because "ldr, =mp" actually ends up being compiled to a pc-relative offset. Basically that means you need to have mp declared close to where you use the ldr.

If moving the source files order around works, then great :).