Sign in Join

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

Mailing lists / fpc-pascal / 2016-01

Can I compile MASM code/file in FPC?

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

silvioprog

Hello,

Can I compile MASM code (or files) in FPC? If so, how to declare some MASM directives like .code, .data?, .const etc.?:

=== begin code ===

program fpcmasm;
{$asmmode masm} // I know, it doesn't compiles, please tell me what I use
:-)
{$i  <Can I include my MASM file here?>}
procedure somefunc; assembler;
asm
  <Can I use my MASM code here?>
end;
end.

=== end code ===

Thank you!

Silvio Clécio
Sven Barth
to silvioprog
"silvioprog" wrote
Hello, Can I compile MASM code (or files) in FPC? If so, how to declare some

MASM directives like .code, .data?, .const etc.?:

You can't. FPC's assembler readers only support a default syntax (usually that what GNU as supports by default) and on x86 platforms also the Intel syntax.
If you want to use MASM you need to assemble it yourself and then $link the resulting file in a unit which also provides access to the functions in the object file using "external".

Regards,
Sven

silvioprog
to Sven Barth
Sven Barth wrote 14 lines
Am 16.01.2016 04:45 schrieb "silvioprog" : > > Hello, > > Can I compile MASM code (or files) in FPC? If so, how to declare some MASM directives like .code, .data?, .const etc.?: You can't. FPC's assembler readers only support a default syntax (usually that what GNU as supports by default) and on x86 platforms also the Intel syntax. If you want to use MASM you need to assemble it yourself and then $link the resulting file in a unit which also provides access to the functions in the object file using "external".

Hm... I already use in that way (however as shared lib), the only cons is that I can't debug it using Lazarus IDE. Anyway, thanks for replying! :-)

Silvio Clécio
Sven Barth
to silvioprog
"silvioprog" wrote
On Sat, Jan 16, 2016 at 5:32 AM, Sven Barth
Show quoted text 6 lines
> > Am 16.01.2016 04:45 schrieb "silvioprog" : > > > > Hello, > > > > Can I compile MASM code (or files) in FPC? If so, how to declare some

MASM directives like .code, .data?, .const etc.?:

> > You can't. FPC's assembler readers only support a default syntax

(usually that what GNU as supports by default) and on x86 platforms also the Intel syntax.

> If you want to use MASM you need to assemble it yourself and then $link

the resulting file in a unit which also provides access to the functions in the object file using "external".

Hm... I already use in that way (however as shared lib), the only cons is

that I can't debug it using Lazarus IDE. Anyway, thanks for replying! :-)

You might not be able to debug the source assembly code, but you can debug the assembler code directly using the Assembler window. Since it's assembler code anyway there won't be that much of a difference. And you can display the Register window as well ;)

Regards,
Sven

silvioprog
to Sven Barth

On Mon, Jan 18, 2016 at 7:09 AM, Sven Barth
wrote:
[...]

Show quoted text 5 lines
You might not be able to debug the source assembly code, but you can debug the assembler code directly using the Assembler window. Since it's assembler code anyway there won't be that much of a difference. And you can display the Register window as well ;)

Very nice! Now I'm debugging it using this windows, that shows the entire assembly code from compiled and linked objects. Thank you very much! :-)

Silvio Clécio