I am using keil and 8051 microcontroller. I want to convert a part of my code written in C into assembly. So for that I wanted to use a variable declared in C file in assembly file.How can I use? I have checked in keil manual also ,there they have given one example code ,in that they have used the variable declared in asm file but not in C. So now how can I do that?
http://www.keil.com/support/man/docs/c51/c51_ap_globalvars.htm You may also write a code fragment first in C and then use the SRC directive to generate an assembler template. http://www.keil.com/support/docs/1275.htm
My 'C' function will be some what like void fun(void) { data byte var1; if(var1 & 0x80) { //some code } if( (var1 & 0x04)||(var1 & 0x03) ) { //some code } ... ... } So I want to convert second if condition into assembly (for that I have created separate asm file , I am not using inline assembly concept)for that var1 is required how can I use? http://www.keil.com/support/man/docs/c51/c51_ap_globalvars.htm In the above link they have given the syntax for inline assembly concept.So here I have created a new asm file so in that how can I use var1 ?
When you made your post, there were 3 bullet points above the 'Message' window - the third of those told you what to do when posting source code. See also: http://www.keil.com/forum/tips.asp Please re-post your code, following the instructions, so that its formatting is retained. To access any symbols between multiple files in any language, the basic principles are always the same: 1. The Defining module must make the symbol "Public"; 2. The Referencing module must have a suitable "External" declaration. You should be able to take it from there...
void fun(void) { data byte var1; if(var1 & 0x80) { //some code } if( (var1 & 0x04)||(var1 & 0x03) ) { //some code } ... ... }
"I want to convert second if condition into assembly" Do you mean:
void fun(void) { data byte var1; if(var1 & 0x80) { //some code } if( (var1 & 0x04)||(var1 & 0x03) ) // Convert this bit? { // //some code // } // ... ... }
Did you really read the information in: http://www.keil.com/support/docs/1275.htm?
View all questions in Keil forum