Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mixing c++ and x86

Status
Not open for further replies.

bob54

Programmer
Oct 26, 2002
3
0
0
GB
Say I have an array A declared in a visual c++ program. I want to be able to access this array in a separate x86 assembly program (a .asm file which is in the same workspace). What are the conventions for doing this? Am I supposed to indicate that the c++ file is a "header file"?

also does anyone have pointers to good tutorials that talk about mixing c++ and x86?

Bob54
 
More generally I would like to know how to refer to a C++ variable from within a separate .asm file containing 8086 assembly code.
Bob54
 
In standard K&R and ANSI C for x86 processors, the label naming convention USED TO BE like this:
In C:
/*Global Variable*/
int A[32];
long another_array[32];

In Asm:
;Defined in .DATA segment/section
EXTRN _A:WORD, _another_array:DWORD

Basically, the C label/variable name is taken, without changing case, and an underscore is slapped on the front of the label.

Unfortunately I doubt if this is still the case in C++, because you can define different functions with the same name but different params. Maybe C++ still works the same with variables. "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Why not using the inline-Assembler (__asm-directive)? Then you have no problem accessing all vars with far ptr directly and debugging is more comfortable.
 
It could be that he wants to write an entire subroutine or library or something in asm... although of course that could be reasonably done using inline asm code...

Entirely possible too that his compiler and his assembler don't agree on a few things about assembly code.

"Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top