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.
Hi, A C function tries to call a assembly function via the interfacing way of c programs-to-assemnly interface. Founded it's failed and can't use step-into to watch the status of assembly function. The codes is as follows. Please give some comments for the issue. Tks!
The codes in C.
BYTE show1[3] ={0x0ff,0x02,0x03}; BYTE t_dat[3]; #pragma NOREGPARMS int wrxdata( BYTE *pDs, /* R1-R3*/ BYTE *pSr /*Fixed memory*/ ); main(){ wrxdata(&t_dat[0], &show1[0]); }
The assembly function.
NAME LB_LIBRARY ?PR?_WRXDATA?LB_LIBRARY SEGMENT CODE ?PD?_WRXDATA?LB_LIBRARY SEGMENT DATA OVERLAYABLE PUBLIC _WRXDATA, ?_WRXDATA?BYTE RSEG ?PD?_WRXDATA?LB_LIBRARY ; Segment for local variables ?_WRXDATA?BYTE: ; Start of the parameter passing seg pSr: DS 2 ; byte pointer variable: pSr pDs: DS 2 ; Additional local variables from 'function' RSEG ?PR?_WRXDATA?LB_LIBRARY ; Program segment _wrxdata: MOV DPTR,#?_WRXDATA?BYTE+0 MOVX A,@DPTR MOV DPTR,#?_WRXDATA?BYTE+2 MOVX @DPTR,A RET ; Return END
"Founded it's failed and can't use step-into to watch the status of assembly function"
'Step-into' is a good debugging tool implemented to figure out what is happening in the program, thats alllright, as long as you dont need an excuse to step-into.
Tks,
"A C function tries to call an assembly function via the interfacing way of c programs-to-assemnly interface."
ya, ok, Assembly cud call a c routine, but the required directives need be Included ie to say Connected
ok, now you cud take a tBRreak
Please give some comments for the issue.
You need to review the different pointer types (generic and memory specific) and their formats in order to make this work.
http://www.keil.com/support/man/docs/c51/c51_le_ptrs.htm
In particular, "generic" pointers (those without a specific memory space specifier) are three bytes long, not two. They include a tag byte for the address space. (That's why they're passed in R1-R3, using three bytes of register space instead of two.)
You don't show the defintion of BYTE, but I assume it's just "unsigned char" or similar, and not something like "unsigned char xdata".