Search code examples
x86assemblyfasm

Assembler: Using "Flat assembler" how do I produce EXE files (compile, link..)?


I'm using FASM to compile a small piece of code:

  mov ah,4ch
  mov al,00
  int 21h 

I click Run -> Compile, and what I get is a .BIN file. sorry for the noobish question but why don't I get an OBJ, or an EXE file, and what is this BIN?


Solution

  • The BIN is a binary file, You need to check the command line options that you used to pass to FASM. According to the documentation the default format is a flat binary file. To quote from the documentation, section 2.4:

    Default output format is a flat binary file, it can also be selected by using 
    format binary directive. This directive can be followed by the as keyword and 
    the quoted string specifying the default file extension for the output file. 
    Unless the output file name was specified from the command line, assembler will
    use this extension when generating the output file.
    

    So I think your code should look like this:

    .use32
    .format pe console
    mov ah,4ch
    mov al,00
    int 21h 
    

    Edit: I just realized after hitting Save, that it was 16 bit registers used...

    .use16
    .format MZ
    mov ah,4ch
    mov al,00
    int 21h