Search code examples
c++cassemblyoperating-systemfasm

How to develop with both Assembly and C/C++ on FASM?


So, I am developing an OS and for now I've been only writing code in assembly. I wish to continue making it with C/C++. The compiler/editor I use is FASM (for Windows). I've tried using MinGW with it, but it gives error when linking fasm's .o file. How can I continue developing with both Assembly and C/C++? Also, I've searched on the Internet a lot, but I didn't find a solution.

Edit: this is the make batch file i'm using:

cls
echo off

fasm.exe los.asm losasm.o
pause
cls
"C:\MinGW\bin\gcc.exe" -nostdlib  los.cpp -o loscpp.o
pause
cls
"C:\MinGW\bin\gcc.exe" -o "C:\Users\helder\Desktop\Lemperyum OperativeSystem I\los" -o -nostdlib losasm.o loscpp.o
pause
cls

pause

Solution

  • FASM is biased toward generating executable files directly as its output, the default being "flat binary output" (see manual). To create object files, you have to use one of the command line options

    • format COFF or
    • format ELF

    Which you choose depends on the other tools. Offhand, I am not sure what type of file MinGW outputs.