Date: Wed, 25 May 1994 12:30:08 -0400 From: morphine AT whatever DOT cs DOT jhu DOT edu (Michael Phelps) Sender: morphine AT whatever DOT cs DOT jhu DOT edu To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: RE: FW: inline assembler code on PC Cc: dj AT ctron DOT com >> Does anybody have examples which use inline assembler code in C programs >> which can be compiled by DJ gcc on MS-DOS 5.0? What is the correct >> compiler directive I have to use? > >Look at in 1.11.maint5. No compiler directives are >required I also want to add inline assembler code, and even after looking at farptr.h, I'm still baffled. I know 8086 assembly language (NOT 80386+), and I find some of the examples in the docs for the GNU assembler to be puzzling. For example, the assembler docs has the following: asm ("movl %0,r9;movl %1,r10;call _foo" : /* no outputs */ : "g" (from), "g" (to) : "r9", "r10"); It almost looks as if the asm() function tries to have a similar format as prinf(), but I don't understand the %0, %1, r9, and r10. Okay, let's say I want to do something really simple and write a routine that will be the same as "x++". Would the following work? asm ("inc %0; : "r" (result) : "r" (input)); What if I don't have it in a function, but rather would like to refer to variables within the C program? (ie, can I say "mov ax, _some_variable;" ?) What I would like to do is to embed assembly language statements like: mov cx, _time_delay; loop1: loop loop1; Is there any way I can do this? Also, one more thing: if I assemble a function with another program and produce and object file to be linked with the compiled C program, how do I retrieve the variables passed to the function? (Are they pushed onto the stack, or what?) I apologize if these questions sound really basic; I just couldn't find enough relevant information in the documentation that I searched through. ---Michael