Arm Community
Site
Search
User
Site
Search
User
Groups
Arm Research
DesignStart
Education Hub
Graphics and Gaming
High Performance Computing
Innovation
Multimedia
Open Source Software and Platforms
Physical
Processors
Security
System
Software Tools
TrustZone for Armv8-M
中文社区
Blog
Announcements
Artificial Intelligence
Automotive
Healthcare
HPC
Infrastructure
Innovation
Internet of Things
Machine Learning
Mobile
Smart Homes
Wearables
Forums
All developer forums
IP Product forums
Tool & Software forums
Pelion IoT Platform
Support
Open a support case
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
Community Help
More
Cancel
Developer Community
Tools and Software
Software Tools
Jump...
Cancel
Software Tools
Arm Development Studio forum
Something about mixed programming,C and Assembly
Tools, Software and IDEs blog
Forums
Videos & Files
Help
Jump...
Cancel
New
Replies
2 replies
Subscribers
127 subscribers
Views
1256 views
Users
0 members are here
Related
Something about mixed programming,C and Assembly
Offline
痕 刘
over 7 years ago
Note: This was originally posted on 28th August 2011 at http://forums.arm.com
Recently I am learning ARM11.in fact ,I am a beginner for ARM.
The processor I use is S3C6410,with ARM1176JZF-S core.Someone who has used this should know that the processor support SD-boot,the way i choose.
The steps to make my program run: first,compile and link the program,generate the binary file.second ,use Winhex tool to copy the content in the binary file to the specific sectors in SD card,where should place the BL1 when using OS.Then put the SD card in the slot,and Power on,the program will run on the processor.
I tried writing the code with assemblylanguage at first,and it worked,the program ran as wished.the assembly code is as followed:
------------------------------------------------------------------------------------------------------
;pheriperal circuit : each of the four ports GPK4 to GPK7 connect a LED
;if this program runs,the four LEDS get on and off one by one
rGPKCON0 EQU 0x7F008800;
AREA LED1,CODE,READONLY ;
ENTRY ;
CODE32 ;
START
ldr r0,=rGPKCON0;
loop
ldr r1,=0x00010000;
str r1,[r0];
bl delay;
ldr r1,=0x00100000;
str r1,[r0];
bl delay;
ldr r1,=0x01000000;
str r1,[r0];
bl delay;
ldr r1,=0x10000000;
str r1,[r0];
bl delay;
b loop;
delay
ldr r3,=0x4ffff;
tag
sub r3,r3,#1;
cmp r3,#0x0;
bne tag;
mov pc,lr;
END
-------------------------------------------------------------------------------------------------------
After this little success,I began another project.I put an assembly source and a C-sourcefile in one project. codes are as followed:
------------------------------------------------------------------------------------------------------
;***code in a.S
AREA LED1,CODE,READONLY
IMPORT xmain
ENTRY
CODE32
START
b xmain
END
//*****code in a.c
#define GPKCON0 (*(volatile unsigned *)(0x7F008800))//
#define GPKDATA (*(volatile unsigned *)(0x7F008808))
void delay(int);
void xmain()
{
GPKCON0=0x11110000; //config GPK4-GPK7 as output ports
while(1)
{
GPKDATA=0x000000f0;//led off
delay(20);
GPKDATA=0x0; //led on
delay(20);
}
}
void delay(int
{
int a=400000;
while(b--)
while(a--);
}
------------------------------------------------------------------------------------------------------
This project still succeeded to compile,0 errors.But when I copy the generated binary file to SD card and Power on,nothing happenned,the LEDs all kept off .It seemed that the program had't run at all!
But,if I remove the "delay" fuction from the code,include the function declaration and the definition, and put several lines of code which have the same effects with the function "delay" where there used to be a calling for "delay", like this:
---------------------------------
......
while(1)
{
GPKDATA=0x000000f0;//led off
//delay(20);
a=8000000;
while(a--);
GPKDATA=0x0; //led on
//delay(20);
a=8000000;
while(a--);
}
......
---------------------------------
then the generated binary file can run in the processor!
So I am confused.I think the effects should be the same,but they aren't.
Can it be that the C fuctions are not allowed to call another sub function in mixed-programing ,or I should add something in my code or config something to guide aARMlinker in RVDS2.2 to link my program correctly?
Another strange thing ,in RVDS environment, it seems that the RO_base doesn't influence the program.I have tried give it different numbers,but it makes no difference,the program can always run normally if I use the valid code. I am not very clear what the RO_base stands for and why it make no difference.
Offline
Peter Harris
over 7 years ago
Note: This was originally posted on 6th September 2011 at
http://forums.arm.com
Your delay loop variables probably also need to be volatile; the compiler is going to see them as "non-functional" and optimize them out.
Cancel
Up
0
Down
Reply
Cancel
Offline
Elf Elf
over 7 years ago
Note: This was originally posted on 6th September 2011 at
http://forums.arm.com
when you say it did not work, what state is the program in? can you break the debugger and check?
what happens when you make the delay function inline? does it work? if it does then my guess is that, delay is pushing something on the stack which you have not setup before. you can disassemble the code and compare the working and non-working code.
Cancel
Up
0
Down
Reply
Cancel
More questions in this forum
By title
By date
By reply count
By view count
By most asked
By votes
By quality
Descending
Ascending
All recent questions
Unread questions
Questions you've participated in
Questions you've asked
Unanswered questions
Answered questions
Questions with suggested answers
Questions with no replies
Suggested Answer
Positioning a function in a Position Independent Executable for ARMV8
0
1654
views
3
replies
Latest
6 days ago
by
Stephen Theobald
Answered
Link a pure binary file to image with scatter file
0
1617
views
3
replies
Latest
7 days ago
by
Ronan Synnott
Answered
Failed to read contents of Internal RAM L1-I_DATA in ARM DS
0
Arm Development Studio
Cache
Debug and Trace Services Layer (DTSL)
4202
views
23
replies
Latest
20 days ago
by
Boon Khai
Suggested Answer
DS-5 connect fail when cortex-r5 is in lock-step mode
0
3872
views
10
replies
Latest
26 days ago
by
Stuart Hirons
Suggested Answer
On Cortex-M4F microcontrollers: is fixed point math faster or floating point?
0
3541
views
10
replies
Latest
27 days ago
by
Ronan Synnott
>
View all questions in Arm Development Studio forum