Date: 02 Apr 1993 00:52:50 -0500 (EST) From: MVICUNA AT delphi DOT com Subject: Re: Inline Assembly To: davisjd AT vuse DOT vanderbilt DOT edu Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Hope I'm not stating the obvious here. asm(asmbler statements : outputs : inputs : registers directly accessed); the first part is simple if you know how to use the asm statement. Outputs, are more tricky. The compiler assumes that only these variables are modified by the asm statement. Its parameter number is %0. Inputs are kinda obvious, there numbers start at %1 ... %N. The registers directly accessed, doesn't seem to work for me. If anyone know where I could find out if this is a bug or what?? inputs/outputs take the form: "(type of register" (variable name) , .... I only know how to use 2 types of variables, you'd need the Gas Sources to look up the i386 machince desciption. the first type is '"r" foobar' which tells the compiler to put foobar into a register if its not all ready in one. the other is '"g" foobar' which, I think, tells the compiler to use its own guess as the best way to use foobar in the asm statement. If its allready in a register put it there, or if you don't need to load it it doesn't you just hafta trust the compiler. The example the use in the extend.tex file which is usefull is this. asm("addl %1,%2" : "2=" result : "g" op1, "r" op2 ); result holds the value of the addl instruction. op2 and op1 are not changed, don't know if that is bug free though. the '"2=" result' tells that same register holds the info for both result and the third paramenter, second input. you can also put in register names like '"%eax" foobar' if you want. Thats a throw back to the older compiler I assume. If you directly access a register in your asm statement, asm("xorl %eax,%eax"); , the compiler will notice that and deal with eax being wiped out. BUT it can't handle things like asm("imul %ebx");. IT won't know that %eax and %edx have been changed. Thats bad. I tried what it says in the Docs, but it don't work. Hopes this helps someone. Thanks, MarkV.