Sign in Join

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

Mailing lists / fpc-pascal / 2015-09

Assembler output

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

José Mejuto

Hello,

Can anybody enlight me in how to:

- Compile a program outputting assembler in intel format.
- Assemble the .s files in a final .exe

I can get assembler in AT&T format using "-a" but if I add "-Anasmwin32" the program is not compiled as "nasm is not found", only main.lpr is compiled, none of the included units (no RTL ones).

It would be great if I only need tools provided by fpc but I think that "as.exe" can not read Intel asm format.

In the case that "as.exe" can not be used for intel format, is there any option out there in order to get the final .exe from the .s files ?

Thank you.

Florian Klämpfl
to José Mejuto
José Mejuto wrote 12 lines
Hello, Can anybody enlight me in how to: - Compile a program outputting assembler in intel format. - Assemble the .s files in a final .exe I can get assembler in AT&T format using "-a" but if I add "-Anasmwin32" the program is not compiled as "nasm is not found", only main.lpr is compiled, none of the included units (no RTL ones). It would be great if I only need tools provided by fpc but I think that "as.exe" can not read Intel asm format.

FPC dependents on a lot of tools like cross binutils which are not provided by FPC itself. So install nasm separately.

José Mejuto
to Florian Klämpfl
Florian Klämpfl wrote
FPC dependents on a lot of tools like cross binutils which are not provided by FPC itself. So install nasm separately.

Hello,

Thank you, so the presence of nasm should make the compiler finish the compilation ? I was thinking that to generate .s output no assembler is needed at all as I do not need the final .exe produced by fpc.

Anyway I'll try to install nasm (or other) and see what happends. Thank you again.

Sven Barth
to José Mejuto: Can anybody enlight me in how to: - Compile a program outputting assembler in intel…
"José Mejuto" wrote 9 lines
Hello, Can anybody enlight me in how to: - Compile a program outputting assembler in intel format. - Assemble the .s files in a final .exe I can get assembler in AT&T format using "-a" but if I add "-Anasmwin32"

the program is not compiled as "nasm is not found", only main.lpr is compiled, none of the included units (no RTL ones).

It would be great if I only need tools provided by fpc but I think that

"as.exe" can not read Intel asm format.

In the case that "as.exe" can not be used for intel format, is there any

option out there in order to get the final .exe from the .s files ?

What is the reason you're trying to do this? Maybe we can help you a bit more if we know your motivation to pursue this.

Regards,
Sven

José Mejuto
to Sven Barth
Sven Barth wrote
What is the reason you're trying to do this? Maybe we can help you a bit more if we know your motivation to pursue this.

Hello,

There are two motivations, the first one is to learn how to do it manually, take a .pas, get the .s and assemble them (and link) to geta final executable.

The second one is to perform some manual changes in the asm code (I know that is very easy to trash it) in order to try to catch some possible optimizations and apply/test them before reach a conclusion about them.

I currently had written a small SQL parser (very limited options, just for the simple purpose of extract some fields from a large dump) and I think the code (tokenizer) should run faster (currently 28 Megabytes / sec in my i7-3770). It has been written with speed in mind, so no ansistrings, not realloc data, fixed and large read buffers, minimized conditionals as much as possible, inline critical functions, etc... There is still a bit of possible optimizations like replacing indirect access (pointer[n]) by running pointers but it will degrade too much the "easy reading" so I thought maybe I can gain some cycles here and there and find a small set of rules (asm sequences) which can be rewritten, something like WPO. But as noted it is more a training in the "how to" than a need to achieve an objective.

Karoly Balogh (Charlie/SGR
to José Mejuto

Hi,

José Mejuto wrote
There are two motivations, the first one is to learn how to do it manually, take a .pas, get the .s and assemble them (and link) to geta final executable.

IIRC it was arguments:
-a -st

This won't assemble or link the executable, but generate a script to compile and link on the target OS. I used this often during early days of the Amiga and MorphOS ports. :)

You can even use the resulting script as a base for your own compile/link experiments.

Charlie

José Mejuto
to Karoly Balogh (Charlie/SGR
Karoly Balogh wrote 10 lines
> There are two motivations, the first one is to learn how to do it manually, > take a .pas, get the .s and assemble them (and link) to geta final executable. IIRC it was arguments: -a -st This won't assemble or link the executable, but generate a script to compile and link on the target OS. I used this often during early days of the Amiga and MorphOS ports. :) You can even use the resulting script as a base for your own compile/link experiments.

Hello,

Great, sure it would be a great start/base point.