flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > [solved] Use C with FASM |
Author |
|
revolution 31 May 2018, 15:53
You can use the "format elf ..." directive to create a file that can be linked with the standard C linkers.
Code: ; fasm example of using the C library in Unix systems ; compile the source with commands like: ; fasm libcdemo.asm libcdemo.o ; gcc libcdemo.o -o libcdemo ; strip libcdemo format ELF include 'ccall.inc' section '.text' executable public main extrn printf extrn getpid main: call getpid ccall printf, msg,eax ret section '.data' writeable msg db "Current process ID is %d.",0xA,0 |
|||
31 May 2018, 15:53 |
|
Fulgurance 31 May 2018, 16:46
Is it not possible without elf or any format ?
And how you link your program and specify start address point ? When i use ld, i have error because i have 64 bits platform... |
|||
31 May 2018, 16:46 |
|
revolution 31 May 2018, 16:50
For 64 bits I think you need "format ELF64".
You might be able to link other formats (mscoff maybe?), but it depends upon your linker, and it depends upon your C code generating something compatible also. |
|||
31 May 2018, 16:50 |
|
Fulgurance 31 May 2018, 19:40
I need ELF64 ? But the output is ELF ?
|
|||
31 May 2018, 19:40 |
|
revolution 01 Jun 2018, 02:12
You will have to ask your linker to make the raw binary after the linking stage.
|
|||
01 Jun 2018, 02:12 |
|
Fulgurance 01 Jun 2018, 07:55
And how you do that ?
|
|||
01 Jun 2018, 07:55 |
|
revolution 01 Jun 2018, 08:05
That depends upon your linker program. Are you using ld?
I remember that MASM had a separate program called exe2bin for converting PE files to binary. |
|||
01 Jun 2018, 08:05 |
|
Fulgurance 01 Jun 2018, 09:07
It's good boy, i have successfully do it ! Just internet don't have many explicit tutorials...
Thanks ! |
|||
01 Jun 2018, 09:07 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.