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.

KEIL:Inserting assembly statement in C source file with KEIL

Status
Not open for further replies.

microT

Newbie level 6
Newbie level 6
Joined
Oct 6, 2005
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,425
how to insert assembly into keil

Help pls !!

I am working with the controller P89LV51RD2 for my application and am using the Keil IDE for writing the application code.

I need to insert few assembly statements in my C source file. I have read the manual and have found abt the #pragma asm/endasm directive, however am still unable to successfully implement this. The stuff in the keil manual is incomplete and very confusing.

I also found number of other option like the use of '__asm' , however even that didnt help.

Pls. help me with this.
Thanx in advance.
 

assembler for p89lv51rd2

I think when you use the ASM directive, you force an assembler output by the compiler of the whole C file. You will then have to assemble the file to get the object code. Seems wierd but I think that's the way it is. As least thats how I think.
 

keil- insert asm code in c code

techie said:
I think when you use the ASM directive, you force an assembler output by the compiler of the whole C file. You will then have to assemble the file to get the object code. Seems wierd but I think that's the way it is. As least what how I think.

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, but I can not test it, because Silabs IDE is more stable when I am debugging 8051F12x with EC2. Forementioned steps work fine for me.

Hope it helps.
 
nop in keil

Thanx for ur response.

I followed the steps given by u ...however still got stuck up at step 3. I will explain what i am doing exactly ...

1) I inserted the required assembly lines between #pragma asm/#pragma endasm statements

2) I used the below options available with µvision2 to generate the .src and .obj file
i) Generate Assembler SRC file
ii) Assemble SRC file

3) However when i try to compile my C file after including the SRC file in my project, i am getting number of warnings (although no errors) like -
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: ?C?ULCMP

Few doubts that i have are -
1) What file should i use to generate the hex code ??
2) Should i directly use the same C file (that was used to create the SRC file) without any modifications ?
3) Should i remove the #pragma asm/#pragma endasm statements ??
 

generate assembler src file keil

microT said:
Thanx for ur response.

I followed the steps given by u ...however still got stuck up at step 3. I will explain what i am doing exactly ...

3) However when i try to compile my C file after including the SRC file in my project, i am getting number of warnings (although no errors) like -
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: ?C?ULCMP

What you are pointing in step 3) is linker complaining about missing standard C library (?C?ULCMP is very probably Unsigned_Long_Compare() ). Of course you do not have this function call inside your code directly, but definitely you have there somethg like "if (x == y)"...

This time I do not be so lazy and I make some quick test to compile BLINKY example with inserted "dummy" asm lines inside uVision2 IDE:
#pragma asm
nop
nop
#pragma endasm

I change "Options for File BLINKY.C" to "Generate Assembler SRC File" and "Assemble SRC File" - as you have done in steps 1) + 2) + I also included C51S.LIB file inside BLINKY project - "Add Files to Group..." - to solve linking troubles which you have mentioned. And everything works fine.

You can ask why C51S.LIB (see directory ..\C51\LIB\) and my answer is, because BLINKY is SMALL memory model project without floating point mathematic. The more information you can find in C51.PDF, Chapter 8 "Library Files".

My appologize for missing info and I hope that everything will start to build fine for you.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top