From: Simon Hammett Newsgroups: comp.os.msdos.djgpp Subject: Some Inline ASM questions Date: Thu, 17 Oct 1996 16:33:41 +0100 Organization: De Montfort University MK Lines: 50 Message-ID: <326651D4.7250@dmu.ac.uk> Reply-To: khcm6sh AT dmu DOT ac DOT uk NNTP-Posting-Host: mkcsug20.mk.dmu.ac.uk 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 Hi all, After trawling throught the FAQ, the GNU C Preprocessor info, and the GCC info I've decided to give up and ask for a hand... in a simple GFX library I'm writting, I want to be able to change what Resolution it works in by chaning a #define statement. This obviously makes changing the code much easier. But I can't find anyway of using a defined macro in a inline ASM("") statement ie: #define HREZ 640 some_routine() { asm (" movl _Y_coord, %eax imul $HREZ, %eax "); } unfortunately this doesn't work as the PreProcessor ignores the HREZ macro, so the linker tripes up. I know I could just use a global varible and use imul _HREZ, %eax, but I'd like to know how to use the #define's in the assembly code. Also, is it possible to pass values to a inline asm, ie write a function entirly in ASM with out having to use global varibles. ie int some_function ( int x, int y ); { asm (" movl X(%sp), %eax imul Y(%sp), %eax movl %eax, RESULT( %sp ) "); } I'd like to be able to do this, without having to guess where the varibles are on the stack, or having to enter absolute values for X, Y and RESULT, which obviously would need changing if the passed parameters are altered. TIA, Sim