Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-08

Porting TP ASM to FPC ASM

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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
Marco van de Voort
to Michael Preslar
Show quoted text 22 lines
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 :-)

Michael Preslar
to Marco van de Voort
> 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}..

.........

Show quoted text 5 lines
> 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
Jonas Maebe
to Michael Preslar
Michael Preslar wrote 7 lines
>> 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