Arm Community
Site
Search
User
Site
Search
User
Support forums
Arm Development Studio forum
printf from assembly
Jump...
Cancel
Locked
Locked
Replies
2 replies
Subscribers
118 subscribers
Views
5770 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
printf from assembly
Avi Levi
over 12 years ago
Note: This was originally posted on 24th June 2011 at
http://forums.arm.com
Hi,
I am trying to call printf from an assembly code but getting into some difficulties.
I found this post:
How to Call a Function from ARM Assembler
However, when using the printf inside my code I get a linker error:
Error: L6238E: foo.o(.text) contains invalid call from '~PRES8' function to 'REQ8' function foobar
Searched for that as well, and found that I am calling a C function that requires 8-byte stack alignment
from an assembly code that does not preserve 8-bytes. (Hence the ~PRES8 and REQ8)
The article suggested that I should add the PRESERVE8 directive before my AREA directive:
add the PRESERVE8 directive to the top of each assembler file. For example, change:
AREA Init, CODE, READONLY
to:
PRESERVE8 AREA Init, CODE, READONLY
But when I do that I get an error that says:
Bad symbol 'AREA' not defined or external.
Can anyone please help me figure out how to do it right?
Thank you
Parents
Scott Douglass
over 12 years ago
Note: This was originally posted on 24th June 2011 at
http://forums.arm.com
PRESERVE8 is a directive by itself and needs to be on a separate line:
PRESERVE8
AREA Init, CODE, READONLY
....
When you use the PRESERVE8 you are promising that any time you branch to an IMPORTED symbol you will have changed SP by a multiple of 8 (including 0). See also
http://infocenter.ar...d/Cacehagj.html
Cancel
Vote up
0
Vote down
Cancel
Reply
Scott Douglass
over 12 years ago
Note: This was originally posted on 24th June 2011 at
http://forums.arm.com
PRESERVE8 is a directive by itself and needs to be on a separate line:
PRESERVE8
AREA Init, CODE, READONLY
....
When you use the PRESERVE8 you are promising that any time you branch to an IMPORTED symbol you will have changed SP by a multiple of 8 (including 0). See also
http://infocenter.ar...d/Cacehagj.html
Cancel
Vote up
0
Vote down
Cancel
Children
No data