🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #4419

C and ASM

#4419
From: Brian K. W. Hook
Date: Tue, 29 Jan 1991 13:50
112 lines
2942 bytes
Newsgroups: comp.os.msdos.programmer
Subject: GRaphics libs for C on DOS
Summary: 
Expires: 
References: <26534@uflorida.cis.ufl.EDU>
Sender: 
Followup-To: 
Distribution: usa
Organization: UF CIS Dept.
Keywords: 

Newsgroups: comp.sys.ibm.pc.hardware
Subject: Northgate Computers
Summary: 
Expires: 
Sender: 
Followup-To: 
Distribution: usa
Organization: UF CIS Dept.
Keywords: 


Newsgroups: rec.guns
Subject: M60 w/night vision scopes
Summary: 
Expires: 
Sender: 
Followup-To: 
Distribution: usa
Organization: UF CIS Dept.
Keywords: 


Newsgroups: comp.os.msdos.programmer
Subject: Assembly and C
Summary: 
Expires: 
Sender: 
Followup-To: 
Distribution: usa
Organization: UF CIS Dept.
Keywords: 


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
Technical Details
Message-ID: <26560@uflorida.cis.ufl.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!pacbell.com!ucsd!sdd.hp.com!samsung!rex!uflorida!reef.cis.ufl.edu!jdb

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!pacbell.com!ucsd!sdd.hp.com!samsung!rex!uflorida!reef.cis.ufl.edu!jdb
From: jdb@reef.cis.ufl.edu (Brian K. W. Hook)
Newsgroups: comp.os.msdos.programmer
Subject: C and ASM
Message-ID: <26560@uflorida.cis.ufl.EDU>
Date: 29 Jan 91 13:50:39 GMT
Sender: news@uflorida.cis.ufl.EDU
Distribution: usa
Organization: UF CIS Dept.
Lines: 112