×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

mixing c++ and x86

mixing c++ and x86

mixing c++ and x86

(OP)
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

RE: mixing c++ and x86

(OP)
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

RE: mixing c++ and x86

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

RE: mixing c++ and x86

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.

RE: mixing c++ and x86

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close