assmbely - c coding mcu8051

Status
Not open for further replies.

Junior Member level 1
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

IanP

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:

Regards,
IanP

Junior Member level 1
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

IanP

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:
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

Junior Member level 1
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

supplementary:

Regards,
IanP

kachuisa

Junior Member level 1
you should use Keil C,include C & ASM

irata

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

bobsanjose

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.