Link Struct / Class From MASM to C/C++???
From: Bryan Parkoff (bryan.nospam.parkoff_at_nospam.com)
Date: 05/31/04
- Next message: Eduardo: "Re: Link Struct / Class From MASM to C/C++???"
- Previous message: Eduardo: "Re: JMP Table in MASM"
- Next in thread: Eduardo: "Re: Link Struct / Class From MASM to C/C++???"
- Reply: Eduardo: "Re: Link Struct / Class From MASM to C/C++???"
- Reply: Eduardo: "Re: Link Struct / Class From MASM to C/C++???"
- Reply: Jim Carlock: "Re: Link Struct / Class From MASM to C/C++???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 31 May 2004 00:22:09 +0000 (UTC)
I place struct in C/C++ source code while I tell MASM to use EXTRN
keyword to link struct from MASM source code to C/C++ source code. The
problem is that struct members can't be used in MASM. "RECORD" is the only
struct name to access three variables: A1, A2, and A3 in C/C++ source code,
but it is not allowed in MASM. It has only one option to substitute from A1
to memory address + 0H, from A2 to memory address + 04H, and from A3 to
memory address +08H. It works fine, but the problem is that I insert or
remove struct members before I must change 04H, 08H, etc to each struct
member in MASM. It is not very flexible.
It would be easier to place variables in global variable rather than
struct member. How do I group global variables together in the global scope
such as ALIGN and CACHE in C/C++ source code while functions in MASM access
C/C++ source code's global variables.
Look at my example code below.
Please advise.
Here is C/C++ source code below.
#ifdef __cplusplus
extern "C"
{
#endif
struct _RECORD
{
U_DWORD A1;
U_DWORD A2;
U_DWORD A3;
};
_RECORD RECORD;
#ifdef __cplusplus
}
#endif
Here is MASM source code below.
.386
.MODEL flat, C
.DATA
EXTRN RECORD:PTR
.CODE
MPU__Run PROC NEAR
XOR EAX, EAX
MOV EAX, [RECORD+00H]
MOV EAX, [RECORD+04H]
MOV EAX, [RECORD+08H]
RET
MPU__Run ENDP
-- Bryan Parkoff
- Next message: Eduardo: "Re: Link Struct / Class From MASM to C/C++???"
- Previous message: Eduardo: "Re: JMP Table in MASM"
- Next in thread: Eduardo: "Re: Link Struct / Class From MASM to C/C++???"
- Reply: Eduardo: "Re: Link Struct / Class From MASM to C/C++???"
- Reply: Eduardo: "Re: Link Struct / Class From MASM to C/C++???"
- Reply: Jim Carlock: "Re: Link Struct / Class From MASM to C/C++???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|