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 > structures in GNU as?

#128315 - kusma - Thu May 10, 2007 3:20 pm

I've been looking at porting Goomba to the GNU toolchains, and I'm currently having issues with the assembly-sources using structures. I can't seem to find any easy way of converting those to GNU as. Does anyone know any tricks I could use? The syntax of the structures in armasm that I'm trying to rewrite is the following:

Code:
MAP 0,gb_zpage
xgb_ram # 0x2000
xgb_hram # 0x80
chr_decode # 0x400
oam_buffer1 # 0x200
oam_buffer2 # 0x200
oam_buffer3 # 0x200

Where gb_zpage is defined as this:
Code:
gb_zpage   RN r11 ;=XGB_RAM

So, if I understand this correctly, something like this:
Code:
adr r2,chr_decode

would bascily do:
Code:
adr r2, [r11, 0x400]

Right? Is there any way of doing things like this in GNU as?

#128316 - kusma - Thu May 10, 2007 3:38 pm

After disassembling the following armasm-code:
Code:
gb_zpage   RN r11

 MAP 0,gb_zpage
xgb_ram # 0x2000
xgb_hram # 0x80
chr_decode # 0x400
oam_buffer1 # 0x200
oam_buffer2 # 0x200
oam_buffer3 # 0x200

 AREA rom_code, CODE, READONLY
   adr r2,chr_decode
 END

I get this:
Code:
ADD      r2,r11,#0x2080

Not quite what I expected, I guess the values after the hash is lengths and not offsets. Still, anyone know of something similar in gcc, or do I need to rewrite this all to non-structs?

#128320 - Dwedit - Thu May 10, 2007 4:16 pm

I've already ported that part of Goomba Color to GCC, but I'm still stuck on other parts. See the thread: http://forum.gbadev.org/viewtopic.php?t=12929

The problems I'm having now are basically "How do I make makefiles", "How do I make CRT0.S" and "How to I make linkscripts".
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#128325 - kusma - Thu May 10, 2007 5:10 pm

Okay, neat. I see we've taken to quite different approaches here. I've tried to keep a working build all the time, so I can verify that it works. I can't seem to get your code to compile at all. For instance wram_globals_start is only found in cart.s, gbz80.s and lcd.s. Where do you get the symbol from, and why isn't it declared anywhere?

#128336 - Dwedit - Thu May 10, 2007 7:23 pm

Because of a limitation of gnu assembler (ADR instruction does not support linking to other files), I ended up making a container file "all.s", which .includes each asm file. I know that it's a very ugly and dirty hack, and completely negates the point of having separate source files.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."