Arm Community
Site
Search
User
Site
Search
User
Groups
Research Collaboration and Enablement
DesignStart
Education Hub
Innovation
Open Source Software and Platforms
Forums
AI and ML forum
Architectures and Processors forum
Arm Development Platforms forum
Arm Development Studio forum
Arm Virtual Hardware forum
Automotive forum
Compilers and Libraries forum
Graphics, Gaming, and VR forum
High Performance Computing (HPC) forum
Infrastructure Solutions forum
Internet of Things (IoT) forum
Keil forum
Morello Forum
Operating Systems forum
SoC Design and Simulation forum
中文社区论区
Blogs
AI and ML blog
Announcements
Architectures and Processors blog
Automotive blog
Graphics, Gaming, and VR blog
High Performance Computing (HPC) blog
Infrastructure Solutions blog
Innovation blog
Internet of Things (IoT) blog
Operating Systems blog
Research Articles
SoC Design and Simulation blog
Tools, Software and IDEs blog
中文社区博客
Support
Arm Support Services
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
Community Help
More
Cancel
Support forums
Arm Development Studio forum
printf from assembly
Jump...
Cancel
Locked
Locked
Replies
2 replies
Subscribers
121 subscribers
Views
4639 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
How was your experience today?
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
Offline
Avi Levi
over 9 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
Offline
Etienne SOBOLE
over 9 years ago
Note: This was originally posted on 24th June 2011 at
http://forums.arm.com
what assembler do you use ?
gcc ?
if you use gcc, write your code in C and then compile it with
gcc -S myfile.c
that will make the assembly code (myfile.s) of your c program.
Then you'll be able to see how the printf work and the syntax will be correct.
Etienne
Cancel
Up
0
Down
Cancel
Offline
Scott Douglass
over 9 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
Up
0
Down
Cancel