[fpc-pascal] Porting TP ASM to FPC ASM
Marco van de Voort
marcov at stack.nl
Mon Aug 21 20:40:49 CEST 2006
> Hope this is the right place to post..
>
> I'm trying to convert some old Turbo Pascal asm to win32 fpc asm and
> dont know where to start..
>
> I'm compiling with -Sd and -Twin32 and {$asmmode intel}..
>
> An example of what I'm trying to port:
>
> procedure ClearFlag(var Flags: word; FlagMask: word); assembler;
> asm
> pop ax
> pop di
> pop es
> not ax
> and es:[di], ax
> end;
>
>
> If I change ax to eax, di to edi and es:[di] to [di], the code compiles
> without warnings or errors, but I don't know if that's the right thing
> to do.
No. The calling conventions are different
> Any pointers, howtos, wiki pages, or whatever else that anyone could
> offer to point me in the right direction would be greatly appreciated..
In this case, I think assembler is slower since it can't be inlined. Note
that TP uses a lot of assembler to workaround non-optimalisation.
IOW just do a :
procedure ClearFlag(var Flags: word; FlagMask: word); inline;
begin
flags:=flags and not flagmask
end;
(and possibly a {$inline on} globally for that unit)
... and hope this code was really rate-determining in speed, since you are
in for a speed boost :-)
More information about the fpc-pascal
mailing list