Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Converting C language to Assembly

Status
Not open for further replies.

zedora786

Newbie level 6
Joined
Jan 9, 2011
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,370
i want to convert my program language from C to Assembly Language. what should i do? i write the C program in Keil. the program in C is

#include<reg51.h>
#include<string.h>
sbit rs=P3^0;
sbit en=P3^1;
void delay(void);
void main(void)
{
unsigned char com[]={0x01,0x02,0x06,0x0E};
int i,lnth;
unsigned char name[]={"Good Day"};
rs=0;
for(i=0;i<4;i++)
{
P2=com;
en=1;
delay();
en=0;
}
rs=1;
lnth=strlen(name);
for(i=0;i<lnth;i++)
{
P2=name;
en=1;
delay();
en=0;
}
while(1);
}
void delay(void)
{
int i,j;
for(i=0;i<50;i++)
for(j=0;j<100;j++);
}


Whats the Assembly of this? How can i convert it??
 

grieblm

Member level 4
Joined
May 7, 2011
Messages
75
Helped
18
Reputation
36
Reaction score
18
Trophy points
1,308
Location
Georgetown, Canada
Activity points
1,734
What you want to do is a non-trivial task because you use the library functions in <string.h>. You would also need to extract these functions and put them in your code.

The easiest way to do this conversion would be to let the compiler generate the assembly code for you as a starting point. Most compilers have an assembly output file as an intermediate code before it gets passed to the assembler and linker. Use this assembly file and optimize to get down to the performance you need.

Why do you need assembly language? Usually, optimizing compilers will do a better job than most beginning assembly programmers will ever be able to do. It usually takes years of practice with assembly language before you can do a better job then the compiler. Just wondering...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top