Since there is not offical reference,I got only one tutorial <a href="http://www.gnupascal.de/contrib/misc/gpcasm.zip"> gpcasm.zip </a>.But when I try to follow the tut and try the inline assembly example on my debian.The gpc was not happy with it. <pre> gnu_asm.pas : In procedure 'MyStupidDelay': gnu_asm.pas:3: error : can't find a register in class AREG while reloading asm </pre>
Here is the code
program gnu_asm; Procedure MyStupidDelay(time : integer); Begin Asm("0 : pushl $0xfffff 1 : decl(%%esp) jnz 1b addl $0x4, %%esp decl %%eax jnz 0b" : : "a" (time) : "eax" ); end;
begin write("only for test"); end.
Another question,are there any other refernece, tutorials, examples on inline assembly in gnu pascal.
thanks.
jcyang a écrit :
Since there is not offical reference,I got only one tutorial <a href="http://www.gnupascal.de/contrib/misc/gpcasm.zip"> gpcasm.zip </a>.But when I try to follow the tut and try the inline assembly example on my debian.The gpc was not happy with it.
<pre> gnu_asm.pas : In procedure 'MyStupidDelay': gnu_asm.pas:3: error : can't find a register in class AREG while reloading asm </pre>
Here is the code
program gnu_asm; Procedure MyStupidDelay(time : integer); Begin Asm("0 : pushl $0xfffff 1 : decl(%%esp) jnz 1b addl $0x4, %%esp decl %%eax jnz 0b" : : "a" (time) : "eax" ); end; begin write("only for test"); end.
Another question,are there any other refernece, tutorials, examples on inline assembly in gnu pascal.
I have nearly no experience with this, but look to the gcc doc "Assembler Instructions with C Expression Operands" specially "clobber", for the gcc version which corresponds to the backend of your gpc I find there (gcc 3.4.4) You may not write a clobber description in a way that overlaps with an input or output operand. AFAIU, the clobber part describes what is used internally by asm, besides the output and input which are already described in the two first parts. This is because gcc is unable to understand the asm language, and needs only to know what registers or memory are used inside to allow him to do register and memory optimisations.
With this in mind your program compiles and work as intended when suppresssing the last part : "eax" , and putting a space between decl and (
Maurice