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.

assmbely - c coding mcu8051

Status
Not open for further replies.

madhun

Junior Member level 1
Joined
Jan 13, 2006
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,424
Hi all

I have to develop code from assembly to c code for an application. I have assembly code with me. Can anybody tell if there is some tool avaliable for that or can anybody show me an example of how to convert a simple assembly program including jumps etc to c program. Please mail the link if its available on any site.

Thanks
Madhu
 

C compilers allow you to embed assembler in your C code by using the #asm/#endasm directives.
To see some examples take a look at:
**broken link removed**

Regards,
IanP
 

Thans for your help
But i am asking for writing a same code in c and assembly i.e. an example for that including jumps. so that i can understand that and write code in c for my assembly code.

Thanks
madhu
 

Have a look at the following example:
Code:
Assembly delay for an Intel 8051 microcontroller:

DELAY:	MOV R0, #ffh			; move 255 to Register 0 (# = immediate)
NEXT:	NOP				; do whatever stuff here
	DJNZ R0, NEXT			; decrement R0, check for 0, jump to NEXT
	RET				; return from subroutine


And now for the 'C' code for the Intel 8051 microcontroller:

void delay (void) {
	int i;
	for (i = 0; i < 0xff; i++)	/* do something 255 times */
		;		/* do whatever stuff here */
}
You just can not compare these two ..
Firstly, familiarize yourself with C for 8051-microcontrollers; there are several books on this subject, for example:
**broken link removed**
And soon you will discover, that you don't need assembly and the way you create codes in assembly, to write programs in C ..

Would you still call it "translation" ?

Regards,
IanP
 

dear Ianp

Thanks for all your help. But I am not able to open the link mentioned by you. Can you pls check that again.

Thanks
Madhu
 

For e-book try this link:

supplementary:


Regards,
IanP
 

you should use Keil C,include C & ASM
 

I haven't found such tool, so you have to get it undstood, the rewrite it in C.
 

Madhu,

there are tools that work from top down, for example from a block diagram level to generate C-Code, then from C-Code to generate Assembly code. The other way round as you ask for it, I have never seen them.
My proposal would be to understand the assmbly code first, document it and then write the C-Code based on the documentation you generated. Any direct translation from C into ASM seems like a dead end.

Bob
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top