#12937 - shadow_gg - Mon Dec 01, 2003 8:33 pm
hello,
in inline asm,what must I do at the end of a block ?
I use r0 up r9 so I do this
stmfd sp!, {r0-r9}
some stuff here
ldmfd sp!, {r0-r9}
but at the end of the block the PC goes in a wrong place like a reset
when I add "bx lr " just at the end, it seems to go each time one instruction before the "bx lr". So my program freeze
What is the problem ?
thx all
#12940 - tepples - Mon Dec 01, 2003 9:28 pm
EDIT: I removed a comment that was completely inaccurate because I didn't see the "inline". Better answer:
I have very little experience with inline assembly, but I can tell you that you have to specify which registers your inline assembly segment clobbers.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#12943 - shadow_gg - Mon Dec 01, 2003 11:13 pm
No I don't use the lr register
I precise too what register I modify
::"m"(camera.x),"m"(camera.y),"m"(camera.z),"m"(data),"m"(fond):"r0","r1","r2","r3","r4","r5","r6","r7","r8","r9");
I can c under VBA that my code works except at the end of the inline block
is there a procedure to do when leaving an inline asm block ?
thx all
#12945 - poslundc - Mon Dec 01, 2003 11:47 pm
I hope someone can provide you with the answer you are looking for, but by now you've probably noticed that many of us don't use inline asm and won't be able to help you out very much with it.
Is there any particular difficulty keeping you from moving the function out of inline asm and into a separate .S file? Perhaps we can help you out with that instead; there are some significant benefits to using separate assembly files, most notably better code organization and, well, more predictable behaviour.
Dan.
#12947 - tepples - Tue Dec 02, 2003 12:37 am
I've chatted with shadow_gg on ICQ, and the problem with going to a separate .s file seems to be that he's converting a graphics engine from C to assembly, and the structs that the graphics engine uses change frequently.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#12949 - poslundc - Tue Dec 02, 2003 12:51 am
Well, I don't want to continue to drive this subject off-topic; I hope that if someone has an answer to the original question they will still post it.
That said, I'd be happy to share my code for a program that generates a header file you can include in your .S files that has #define statements for all of your structs. With the proper makefile directives, you can set it up like I have so that any changes to the header files with your original structs in them will cause the makefile to recompile and relaunch the generator, so your ASM files use the proper offsets. No muss, no fuss.
The only caveat is that the compiler you use on your host computer must match variable size and struct generation with the compiler you use for the gba (ie. gcc for my Mac lays out its structs the same way gcc for the GBA does). I imagine this would be the case on Windows machines running gcc as well.
Dan.
#12954 - shadow_gg - Tue Dec 02, 2003 1:09 pm
I had found the solution in another topic ^^
it 's because the cpu goes into the .pool directly at the end of my function
I had solve it by removing .pool
thx all