Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How Embedded C program is converted into Instructions?

Status
Not open for further replies.

Surender Reddy

Full Member level 2
Full Member level 2
Joined
Jan 28, 2012
Messages
129
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Location
Bangalore, India
Visit site
Activity points
2,186
Hi,

I am working with programming microcontroller in C language. The C statements should convert into assembly instructions.
My doubt is "Single C statement converted into how many instructions?"

Ex: int a=23; how many instructions it takes
Ex: if(a>b)
if((a>b)&&(b>c)&&(a<c)) //a,b,c are variables
how many instructions it takes for both statements?
 

How c codes are converted into assembly instructions is really depends on the tool sets you utilize, it varies between compilers and type of optimization used.
 

There is no single answer. It depends on the processor, the compiler, and the compiler options, the source code and the neighbouring source code.

The only way to find out is to look at the compiler output. Learning the correspondence between source code and processor instructions is a valuable skill that many people don't have.

Be aware that if you have processor instruction/data caches then the execution time will vary depending on whatever has been executed in the past - -i.e. whether or not the code/data is in the cache. For hard real-time systems that is a major consideration, since with modern processors the mean:worst time is >1:100
 

I am working with programming microcontroller in C language. The C statements should convert into assembly instructions.
Sounds like you already selected a specific processor family. It's quite easy to write an example C program and check how it's translated to assembly by looking at the list file.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top