Topic : Novice Question

Forum : 8051

Original Post
Post Information Post
February 23, 2007 - 10:14am
Guest

Dear Member,
I am new in RIDE. I make simple C and ASM. Below is ASM program. The file name is ASM_TEST.A51
asm_try segment code
public ?asm_try
rseg asm_try
?asm_try:
mov P1,#03Dh
ret
end
C program as follow (file name is Try_ASM0.c) :
#include
extern void asm_try(void);
void main()
{
asm_try();
}
After I "Make All", there is error ERROR#46 : Undefined Symbol (Pass-2)-'P1'. Then I change P1 (in ASM) to 080h. After compiling, there is another error "Unresolved External Symbol :asm_try(Try_ASM0). Could you please advice what shall I learn to avoid such error in future? I am using demo version. Thank you for your help.

Regards,
Arianto W.

Replies
Post Information Post
+1
0
-1
February 23, 2007 - 10:23am
Guest

Hello,

if you prefix your assembly routine name by a question mark like in 'public ?asm_try', it means that you define this routine as reentrant.
So in the Try_ASM0.c file, you should define the external function like this: extern void asm_try(void) reentrant;
About the P1 symbol undefined, two options:
- 'Options->Project->MA51->Source' ==> check 'Define symbols for the 8051 function registers', OR
- add the line $include(reg51.inc)
at the beginning of ASM_TEST.A51.

regards,
Lionel

+1
0
-1
February 27, 2007 - 11:36am
Guest

Dear Lionel,
Thanks for the answer. After I do what you suggested, there is another error in linker process : ERROR100: UNRESOLVED EXTERNAL SYMBOL: asm_try(TRY_ASM0). What shall I do? What page in MA51 and LX51 document shall I read? Thank you for your help.

Regards,

+1
0
-1
March 2, 2007 - 8:52am
Guest

Because your function does not handle any parameter, the naming is just "asm_try" (see the listing of the C file). In that case, you have to name the assembly function asm_try instead of ?asm_try (just remove the question mark).
Francis

+1
0
-1
March 2, 2007 - 3:52pm
Guest

on the subject of calling asm from C there is one simple surefire way that solves all hassle.

make a skeleton function in C and use the generated asm as the base for your assembly code. All naming conventions, register use and who knows what else, will come out right.

Erik