#15419 - Steve++ - Thu Jan 22, 2004 11:17 am
I'm just starting out GBA dev. I want to start with assembly because I'm not afraid of it (have used PIC assembly, did a bit of Intel years ago) and I think it's a great way to get to know the GBA (and I'm a control freak). Anyway...
I want to use the GNU assembler (not goldroad) in either the devkitadv or HAM environment (not using HAMlib). I'm just not sure what happens when I assemble a file. I've come across documents about the COFF and ELF formats, but they are huge and complicated.
First of all, what exactly happens when I do the following?
gcc -o game.elf game.S
objcopy -O binary game.elf game.bin
(or something like that)...
Is it the same under devkitadv as in HAM?
What about the COFF (.o) format? How do I use that? If I write a program and assemble it to a .o file, won't the program start location be in the wrong spot (i.e. 0x00000000 instead of 0x8000000)? Do I have to pad the beginning of the file with 33,554,432 nops (128 MB) to get the right start location? Or is there a way to tell the assembler that the program will be loaded from address 0x8000000 instead of 0x000000? Will the linker completely screw with my programs' addresses so that, for example, when I refer to address 0x000000, the same code in the final binary file will get converted to 0x8000000? What gets relocated and what doesn't?
I would have thought converting assembly language to raw binary executable code would be a very simple manner. Why is this not the case? (Grrrr....!)
Last questions: if i get this all to work, how do i set aside space for the header? I've heard VBA doesn't care whether or not a header is present - but how does it know whether or not it's there? The first word in the header is a pointer to the start of the program, right? If VBA doesn't care whether or not there is a header, how does it know what to do with the first word (i.e. how does it know whether it should jump to that memory location or execute the word itself?)?
I don't care what's in the header (except for the first word) because i know my soon-to-arrive flash cart will insert it, but i've heard that space should be set aside anyway, as the flash cart isn't going to relocate the code (i definitely wouldn't want that to happen!!).
Sorry for the barrage of questions. I've been reading stuff for the last couple of weeks and it seems that this basic information isn't available.
Thanks to anyone who takes the time to read this and/or reply.
I want to use the GNU assembler (not goldroad) in either the devkitadv or HAM environment (not using HAMlib). I'm just not sure what happens when I assemble a file. I've come across documents about the COFF and ELF formats, but they are huge and complicated.
First of all, what exactly happens when I do the following?
gcc -o game.elf game.S
objcopy -O binary game.elf game.bin
(or something like that)...
Is it the same under devkitadv as in HAM?
What about the COFF (.o) format? How do I use that? If I write a program and assemble it to a .o file, won't the program start location be in the wrong spot (i.e. 0x00000000 instead of 0x8000000)? Do I have to pad the beginning of the file with 33,554,432 nops (128 MB) to get the right start location? Or is there a way to tell the assembler that the program will be loaded from address 0x8000000 instead of 0x000000? Will the linker completely screw with my programs' addresses so that, for example, when I refer to address 0x000000, the same code in the final binary file will get converted to 0x8000000? What gets relocated and what doesn't?
I would have thought converting assembly language to raw binary executable code would be a very simple manner. Why is this not the case? (Grrrr....!)
Last questions: if i get this all to work, how do i set aside space for the header? I've heard VBA doesn't care whether or not a header is present - but how does it know whether or not it's there? The first word in the header is a pointer to the start of the program, right? If VBA doesn't care whether or not there is a header, how does it know what to do with the first word (i.e. how does it know whether it should jump to that memory location or execute the word itself?)?
I don't care what's in the header (except for the first word) because i know my soon-to-arrive flash cart will insert it, but i've heard that space should be set aside anyway, as the flash cart isn't going to relocate the code (i definitely wouldn't want that to happen!!).
Sorry for the barrage of questions. I've been reading stuff for the last couple of weeks and it seems that this basic information isn't available.
Thanks to anyone who takes the time to read this and/or reply.