Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help integrarting assembler with C++

Hi. Well, I am trying to learn how to integrate .asm files with .cpp files. I got the source code of two simple "hello world" programs that should work together, but I dont know how to compile them and link them together. I tried with Borland c++Builder (because it also includes "tasm" for the assembler code), but I get error messages creating the .obj, and I havent been able to solve it.

So, which progs/compilers can I use? Thanks.

The files are:

/************************/
#include
#include

extern "C" {
void far MySub();
}

char *myHelloMsgC = "Hello World from C++";


void main() {
cout << myHelloMsgC << endl;
MySub();

getch();
return;
}


/************************/

PAGE 255, 255
TITLE hello2.asm,

PUBLIC _MySub

.MODEL SMALL, C
.486

DOS EQU 21h
CR EQU 13d
LF EQU 10d
SE EQU '$'

.DATA

myHelloMsgE DB "Hello World from Assembler", CR, LF, SE

.CODE

_MySub PROC FAR
PUSH AX
PUSH DX

MOV DX, OFFSET myHelloMsgE
MOV AH, 09h
INT DOS

POP DX
POP AX

RET
_MySub ENDP

END

Comments

  • CoNsTrIcToRCoNsTrIcToR Member Posts: 25
    have you also got Microsoft VC++ ???
    maybe i can help you with that.

    btw when i did it using MVC++, it gave me an "access violation" error due to the 'int 21h' instruction, which makes sense.

    in MVC++, assembly instructions are included in main as follows:

    _asm {
    //..your code..//
    }
Sign In or Register to comment.