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
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".