bluebird031198
asked on
Linking Assembly code to C++
can anybody help me how to create a link-able macro in Assembly language for C++ source code?
for example I want to create some routines in assembly that handle disk I/O and want to link them to my C++ code.
for example I want to create some routines in assembly that handle disk I/O and want to link them to my C++ code.
What operatig system? DOS I assume?
Is this for the x86 computers?
What C++ compiler?
Why not provide at least one example procedure of what you want?
Is this for the x86 computers?
What C++ compiler?
Why not provide at least one example procedure of what you want?
ASKER
if can just give some examples in DOS, Unix, or even others OS.
thanks for all
thanks for all
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
; A convenient macro for making DOS interrupt service calls.
BDOS MACRO U,V
IFNB <V>
MOV AL,V
ENDIF
MOV AH,U
INT 21H
ENDM
; Assemply procedure top opne a file in DOS. Caller specifies the file name and the mode to open in. Procedure returns a non-zero handle if it succeeds. zero if it fails.
; Returns
; AX file handle.
OPNFIL PROC NEAR PASCAL DWORD FILNAM,BYTE OPNMOD
LDS DX FILNAM
BDOS 3Dh,OPNMOD
JNC OPNFILEND:
XOR AX,AX
OPNFILEND: RET
OPNFIL END
BDOS MACRO U,V
IFNB <V>
MOV AL,V
ENDIF
MOV AH,U
INT 21H
ENDM
; Assemply procedure top opne a file in DOS. Caller specifies the file name and the mode to open in. Procedure returns a non-zero handle if it succeeds. zero if it fails.
; Returns
; AX file handle.
OPNFIL PROC NEAR PASCAL DWORD FILNAM,BYTE OPNMOD
LDS DX FILNAM
BDOS 3Dh,OPNMOD
JNC OPNFILEND:
XOR AX,AX
OPNFILEND: RET
OPNFIL END
from C++ you would use.
extern "C" HANDLE OPNFIL(char *FilNam,char Mode);
handle FilHnd = OPNFIL("c:\autoexec.bat",0 );
extern "C" HANDLE OPNFIL(char *FilNam,char Mode);
handle FilHnd = OPNFIL("c:\autoexec.bat",0
That's about the best I can offer without more input from you.
Can you provide some details.?