/*******************************************/ /*compiler Keil C51 v6.23*/ /*name:main*/ unsigned char xdata temp; unsigned char xdata *p; void func(void); void main(void) { unsigned char xdata i; while(1) { p = &temp; *p = 98; func(); i = *p; } } /******************************************/ /*-------------------------------------- compile following program to assembly program, then link with the main function.ERROR!!! Why and how to chang the assembly program.please help me,thank you.! ------------------------------------------*/ #pragma src(MYPTR.A51) small extern unsigned char xdata *p; void func(void) { *p = 0xdd; } my E-mail:inspra@xjgroup.com name:huangjian
It appears that your C program which you use SRC with is ALWAYS compiled in SMALL memory model. The following line:
#pragma src(MYPTR.A51) small
"the program fly away" What does that mean?
Yes,you are right.Thank you very much! But when I chang memory model from SMALL to LARGE or COMPACT,the program fly away.Please tell me why and how to adjust it.
using a single-character name like 'p' is not a good idea for a global variable! The AX51 & A251 assemblers have a CASE control to make them case-sensitive; otherwise, they are not. I couldn't find it actually stated in the manual, but I assume that A51 must be case-insensitive?
P is sbit in the PSW register. Use another name other than p.
What error? Jon
Read the section on pointers in the C51 manual - this tells you how pointer values are actually represented in memory. Then all you need to do is write your assembler accordingly to use those values!