Hello,
I would like to write a few functions using assembly in my C program, for GBA.
I don't find the documentation explaining how to do that. I tried to read the source code of the libgba, but it is still unclear to me how parameters are passed from the C function declaration to its assembly implementation.
Could someone explain me or point me to a documentation, please ?
How to use assembly in the source code ?
Re: How to use assembly in the source code ?
Use this code as a template (save it with .s extension):
The ARM calling convention is simple: all parameters are made 32-bit (sign-extending if necessary), the first four parameters go in the r0-r3 registers, all others are pushed on the stack.
Links:
Tonc: Whirlwind Tour of ARM Assembly
[PDF] ARM Architecture Procedure Call Standard (AAPCS)
Code: Select all
.arch armv4t @ target the ARMv4T architecture (on which the GBA's ARM7TDMI processor is based)
.section .iwram, "ax", %progbits @ use fast 32k RAM for ARM code
.align 2
.global myFunc
myFunc:
bx lr @ return
Links:
Tonc: Whirlwind Tour of ARM Assembly
[PDF] ARM Architecture Procedure Call Standard (AAPCS)
Donate to devkitPro - help us stay alive!
Re: How to use assembly in the source code ?
Thank you a lot, that's all I needed.
Who is online
Users browsing this forum: No registered users and 3 guests