Porting TP ASM to FPC ASM

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Porting TP ASM to FPC ASM

Michael Preslar
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.

Any pointers, howtos, wiki pages, or whatever else that anyone could
offer to point me in the right direction would be greatly appreciated..

--
Michael
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Porting TP ASM to FPC ASM

Marco van de Voort
> 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 :-)
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Porting TP ASM to FPC ASM

Michael Preslar
>> 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}..
.........
>> 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 further information you could give? The documentation doesn't have
any specifics on the differences..

> 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 :

This tackles one procedure but there are a good dozen or so more to go.
Having someone help port them would be quickest, but I won't learn how
to maintain them myself..

> (and possibly a {$inline on} globally for that unit)

{$inline on} ? Never heard of this one.. What's it do?

--
Michael
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Porting TP ASM to FPC ASM

Jonas Maebe-2

On 22 aug 2006, at 11:44, Michael Preslar wrote:

>>> 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 further information you could give? The documentation doesn't  
> have any specifics on the differences..

Porting 16 bit assembler for a segmented memory model to a 32 bit  
selector/offset memory model is not something which can be shortly  
summarised, and it's not possible by simply replacing a few  
statements by others.

> This tackles one procedure but there are a good dozen or so more to  
> go. Having someone help port them would be quickest, but I won't  
> learn how to maintain them myself..

You have to understand what the assembler code does to be able to  
port it to 32 bits, regardless of whether you want to keep it in  
assembler or translate it into Pascal.

>> (and possibly a {$inline on} globally for that unit)
>
> {$inline on} ? Never heard of this one.. What's it do?

It turns on support for the "inline" keyword, which says that the  
code in a procedure's body should be inlined at calling sites.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal