We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am writing a small C function which is suppose to replace the assembly function My rest code is written in assembly and the assembler (asm51) is used The data declaration is done as
t33 EQU 53H t34 EQU 54H t35 EQU 55H t36 EQU 56H t46 EQU 0A7H
MOV A,t32 CJNE A, #1FH,Chk
t32 DATA 52H t33 DATA 53H t34 DATA 54H t46 DATA 0A7H
extern unsigned char t32;
MOV R0,#t46
"Now here the t32 is a macro definition" So it's not a variable! You need to #define it in a 'C' header file; then both C51 & A51 can share the header file. See the Manuals, and do a Search here - we've been through it all very recently!
No when i went through the keil's assemblers user's guide the EQU & SET are refered as macro definers As you can see
MOV A,t32
Andy i tried posting the same message on 8052 as you were logged in the main problem is the program is approved by the departments and attached in ISO documents so i cannot change the source code addresses. regards sachin
the EQU & SET are refered as macro definers Where ever did you get that idea? I just checked to be sure, and they're not. They're documented as symbol definitions. A symbol is a rather completely different thing than a macro. I'm not aware of any method that would let compiled C code access symbols that don't follow the C compiler's symbol naming conventions as described in the C51 manual. To interface asm to C51 code, the assembly code has to be adapted. Since you say you can't do that, odds are you're stuck solid. It looks like you're in well over your head here. I suggest you request help from your colleagues immediately.
"To interface asm to C51 code, the assembly code has to be adapted. Since you say you can't do that, odds are you're stuck solid." You could always write a little Assembler function to allow 'C' access to your incompatible, immutable code?
The only problem this is the only copy of code i have. There isn't anybody who even know what and how it is writen. If you want you can see the files posted at http://www.8052.com/user/ssachin/firstasm.a51 http://www.8052.com/user/ssachin/keyboard1.c I have tried to comment kbrd: which is a keyboard function in firstasm.a51 file But one thing can help me if any body tell me how to declear a variable in assembly at a perticular location (eg. t32 at 0x52) which can be accessed by my C function. As right now i am returning a value (R7 stores my return value) and then in assembly using that returned value (R7) to put in t32
MOV t32,R7
small mistake http://www.8052.com/user/ssachin191/firstasm.a51 http://www.8052.com/user/ssachin191/keyboard1.c thanks sachin
how to declear a variable in assembly at a perticular location (eg. t32 at 0x52) which can be accessed by my C function. So you don't really need the name of the assembly variable --- you know it's absolute address. That's an entirely different story then. Just use the absolute memory access macros from <absacc.h>, then. Your goal is at DBYTE[0x52].
really a big mistake please see http://www.8052.com/users/ssachin191/firstasm.a51 http://www.8052.com/users/ssachin191/keyboard1.c
hi there I have tried absass.h but with that I can read the data from that perticular location. What if i want to write at that perticular location?? eg.
#define final DBAYTE[0x52] void some_function() { final=0x03;// 0x03 is just a sample value }
"This is the real thing i want to do, I mean, I want to write the result of my C function in a variable located at (0x52)" No, you do not want to do that! You already have the variable in assembler; you want to be sure that 'C' is writing to the same place as your assembler. Therefore you should just use variable name. Otherwise, you will have to remember to update the 'C' if the assembler ever changes. That is a really bad idea! http://www.8052.com/forum/read.phtml?id=60929
It's not clear to me that there is a requirement to locate the variable at an absolute location. If not, you might be interested in the "Memory Initialization" and "Reserving Memory" section of the assembler manual with DB / DS. Did you use the PUBLIC declaration to export the DATA symbol so the linker can find it? E.g., PUBLIC t32 You can then use the C statement extern U8 t32; to access the variable from C. Note that you cannot export EQUates; those are not actually symbols in the object file, but more like a #define macro.
Thanks every body for your help I did following changes and it is worknin fine. Declearation: -
t32 DATA 0x52 PUBLIC t32
extern unsigned char t32; //used t32 for storing the answer // of C function