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
 

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

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,435
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:
ftp://user:user@elektroda.kicks-ass.net/eva/embedded_c_561.pdf
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
 

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

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,435
For e-book try this link:

supplementary:


Regards,
IanP
 

kachuisa

Junior Member level 1
Joined
Nov 16, 2005
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,401
you should use Keil C,include C & ASM
 

irata

Junior Member level 3
Joined
Dec 31, 2005
Messages
28
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,281
Activity points
1,495
I haven't found such tool, so you have to get it undstood, the rewrite it in C.
 

bobsanjose

Advanced Member level 1
Joined
Jan 13, 2006
Messages
416
Helped
56
Reputation
112
Reaction score
21
Trophy points
1,298
Location
Silicon Valley
Activity points
5,228
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

Top