#26467 - funkeejeffou - Thu Sep 16, 2004 1:40 pm
Hi,
As I'm changing apartment soon, I won't have the internet for maybe a month. However I must keep coding the project I'm actually on(pretty interesting huh :-); that is why I'm posting here today cause tomorrow internet will be gone :(
I'm currently using DevKitARM R8, and as I need to optimize a lot my code, I have thought of using ASM written functiuns in a big main C program(the forum members seems to prefer this over inline assembly).
The problem is, after searching for two nights on gbadev.org and google, I couldn't bring up myself with answers, and it seems that no special docs exists on mixing GAS and C.
I would just like to have a clear and complete method on this topic so that I understand what is happening and so that I can code peacefully.
So please help me out with these little questions :
1)How do I create the general structure of my program, providing the main file and functiun are in C code, and can call ASM functiuns located in IWRAM(ARM Code) or EWRAM(Thumb Code).
2) How do I create an ASM functiun in a separate file so that the main program will know its existence. How do I call this functiun? How do I retrieve the parameters I've sent to it(in ASM), how do I return a value and use it in C code?
3) How can global variables be accessed in ASM?
4) Can I know what is the first free adress in RAM when using ASM, and can I move the heap after alocating memory?
5) How can I force the ASM functiuns and the C one to be in thumb or ARM, and in IWRAM, EWRAM or ROM?
6) What is the way of compiling a big project like this with C, ASM functiuns in ROM, RAM and ARM/Thumb(makefile)?
7) If there is a sourcecode somewhere concerning this code architecture, I'd be happy to have the link.
Thanks in Advance !
PS : I know these questions are often asked here, but the answers aren't always clear. Maybe it would be a good idea putting the answers in Tepples GBAdev Frequently asked, or creating a good tutorial on it.
As I'm changing apartment soon, I won't have the internet for maybe a month. However I must keep coding the project I'm actually on(pretty interesting huh :-); that is why I'm posting here today cause tomorrow internet will be gone :(
I'm currently using DevKitARM R8, and as I need to optimize a lot my code, I have thought of using ASM written functiuns in a big main C program(the forum members seems to prefer this over inline assembly).
The problem is, after searching for two nights on gbadev.org and google, I couldn't bring up myself with answers, and it seems that no special docs exists on mixing GAS and C.
I would just like to have a clear and complete method on this topic so that I understand what is happening and so that I can code peacefully.
So please help me out with these little questions :
1)How do I create the general structure of my program, providing the main file and functiun are in C code, and can call ASM functiuns located in IWRAM(ARM Code) or EWRAM(Thumb Code).
2) How do I create an ASM functiun in a separate file so that the main program will know its existence. How do I call this functiun? How do I retrieve the parameters I've sent to it(in ASM), how do I return a value and use it in C code?
3) How can global variables be accessed in ASM?
4) Can I know what is the first free adress in RAM when using ASM, and can I move the heap after alocating memory?
5) How can I force the ASM functiuns and the C one to be in thumb or ARM, and in IWRAM, EWRAM or ROM?
6) What is the way of compiling a big project like this with C, ASM functiuns in ROM, RAM and ARM/Thumb(makefile)?
7) If there is a sourcecode somewhere concerning this code architecture, I'd be happy to have the link.
Thanks in Advance !
PS : I know these questions are often asked here, but the answers aren't always clear. Maybe it would be a good idea putting the answers in Tepples GBAdev Frequently asked, or creating a good tutorial on it.