From: Chris Frolik Newsgroups: comp.os.msdos.djgpp Subject: inline __asm__ with djgpp Date: Thu, 10 Jul 1997 13:57:54 -0500 Organization: IndyNet - Indys Internet Gateway (info AT indy DOT net) Lines: 60 Message-ID: <33C530B2.55A7@indy.net> NNTP-Posting-Host: ip75-246.ts.indy.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I am starting to learn assembly language, and I am already pretty familiar with C and C++. I would like to try some in-line assembly code in DJGPP, but I am not quite sure how. I tried the following C program: /* BEGIN program */ #include int multiply(char); /* function prototype */ int main() { char x=5; int result; result = multiply(x); printf("\nThe result of the multiplication is %d\n", result); return 0; } int multiply(char c) { short int r; /* Assembly routine to multiply c by 2: */ __asm__ (" movb $2,%ax imulb c movw %ax,r "); return (int)r; } /* END program */ I just wrote this to see if I could get inline assembly routines to work with DJGPP. When I compile, it tells me that 'c' and 'r' are undefined. I am assuming it means they are undefined within the assembly code. I read the FAQ on this, and then the text info docs that it pointed me to. I didn't understand the method it tells me to use, and I want to use the standard ANSI C inline assembly method, like in Pascal. So, my question is how do I pass variables to assembly routines in this method? I apologize if my assembly code is incorrect since I am still trying to learn the language. It is bad enough that my tutorial book covers Intel assembly, and DJGPP requires AT&T assembly. Thanks, -Chris