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.

Register Log in

Inserting C-code in assembly language

Status
Not open for further replies.

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,146
Reputation
4,298
Reaction score
2,087
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
Yes it is definetely possible.... which controller and IDE are you using....

Mixing Assembly and C
http://myweb.msoe.edu/~barnicks/cou...s/Mixing C and assembly language programs.pdf

I will try to explain your steps more precisely. What you exactly need to do is:
1) Insert your assembly lines between #pragma asm/#pragma endasm statements
2) Start the file_name.c file with #pragma src (it must be the first line there)
3) Insert file_name.src - this file will be generated during compilation process - inside your project.

Of course, this can be done automagicaly inside uVision2, at least it is described so inside C51.PDF,
 

yadavvlsi

Advanced Member level 3
Joined
Nov 19, 2010
Messages
978
Helped
485
Reputation
968
Reaction score
454
Trophy points
1,343
Location
Bangalore, India
Activity points
6,990
Some of compliers allows writing assembly language code with C language. In this case you need to you need to specify starting and ending of assembly code with in C code. But I don't think you can add C code in assembly. Assembly code is converted in to machine code by assembler while C code requires a complier.
 

Joyhtidas

Member level 4
Joined
Nov 30, 2009
Messages
72
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,288
Location
Bangalore, India
Activity points
1,709
Hi,
Thank you Shivram Sir,
I am using C30 compiler
It is very hard to find any sample code of this
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,483
Helped
14,048
Reputation
28,351
Reaction score
12,706
Trophy points
1,393
Location
Bochum, Germany
Activity points
276,136
I am using C30 compiler
It is very hard to find any sample code of this
When mixing C and assembly language , you'll need to process the source with a C-compiler rather than an assembler. So whatever you define it, the actual problem is to insert assembler into C-code, because the latter is the compiler's native language. But that's no problem so far.

Regarding syntax details, did you notice that C30 is shipped with a lot of manuals and help files? That's basically the place to search for the mixed language syntax. Im also sure that you'll find examples.

Generally, you should consider, that using C code has some prerequisites. In most cases, it has to be embedded in a C based application, involving startup code, libraries, stack initialization, reserving registers and so on. The idea of inserting C-code into assembly language may also conflict with these requirements.

P.S.: If you tell more about your intentions, we can possibly give detailed suggestions.
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,146
Reputation
4,298
Reaction score
2,087
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
Yes FVM is correct..... the modification of the startup code has to be very carefully and with some good expertise level....
the Help in the IDE are always the best helping manual we can get......
 

Joyhtidas

Member level 4
Joined
Nov 30, 2009
Messages
72
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,288
Location
Bangalore, India
Activity points
1,709
Hi ,
Actually I need to use the bootloader for my project.
So we already built our own controller board. When i test the ds30 bootloader application
it is not working, but it works with the Explorer16 development board. So i am troubleshooting it.
I didn't got the result with our own board.

So what are the things to be checked? Can you suggest some ideas

Thanks
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,483
Helped
14,048
Reputation
28,351
Reaction score
12,706
Trophy points
1,393
Location
Bochum, Germany
Activity points
276,136
So what are the things to be checked? Can you suggest some ideas
Trace the bootloader execution with a hardware debug adapter in MPLAB and check where it fails. That's what I do in a similar case, and the method was always successful up to now.
 

Joyhtidas

Member level 4
Joined
Nov 30, 2009
Messages
72
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,288
Location
Bangalore, India
Activity points
1,709
Hi,
I checked the hardware. The MAX232 Receiver is working, but it is not transmitting anything
Whether the 'Configuration Bits ' will be the problem?
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top