[comp.os.msdos.programmer] Assembly and C

jdb@reef.cis.ufl.edu (Brian K. W. Hook) (01/29/91)

What is the functional difference between using the following methods to
interface with assembly?  Please note functional difference meaning
size, speed, etc.

Ex. 1: (USING PSEUDO-REGISTERS)

void function ( void )
{
	_AX=(some number);
	_BX=(some number);
	_CX=(some number);
	_DX=(some number);
 	geninterrupt(someinterrupt);
}

Ex. 2:  (USING INT86())

void function2 ( void )
{
union REGS regs;

	regs.x.ax=(some number);
	regs.x.bx=(some number);
	int86(interrupt,&regs,&regs);
}

Ex. 3:  (USING INLINE ASM)

void function3 ( void )
{
	asm {
		mov    ax,(some number)
		mov    bx,(some number)
		mov    cx,(some number)
		int    (some interrupt)
	}
}

Ex. 4:  (USING SEPARATELY COMPILED MODULE)

func4.asm

(ASSORTED ASSEMBLY ROUTINES)

main.c
{
....
func4();

....
}

I want to integrate some assembly routines into my code, but I have not
found a real good, comprehensive, and readable text on integrating C with
assembly language.  Most of the books are terse, cover topics that have been
rehashed over and over (interfacing to the BIOS, interfacing to DOS, writing
windowing libraries, or writing TSRs), are too general in nature, or too
specific ("this code was written using MSC5.1 and MASM 5.0....it is easily 
modified to run with TC 2.0 and TASM 1.0"--this leads me to say 'if I could
rewrite it for another compiler and assembler, why am I reading this book?').

My point is, do I gain any forseeable speed or size benefits by writing 
ASM routines, compiling them to .OBJ, then linking, or will one of the
other three routines work just as well (or close enough).  I like the first
three methods since they all take care of cleaning up the stack, finding
variables, etc. etc.  Much easier to deal with.

Brian