Link to home
Start Free TrialLog in
Avatar of bluebird031198
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.
Avatar of nietod
nietod

Yes, I can help.  If you want qualifications, I've written a 500,000 line assembly language program.

Can you provide some details.?
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?

Avatar of bluebird031198

ASKER

if can just give some examples in DOS, Unix, or even others OS.
thanks for all
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
; 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
from C++ you would use.

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.