Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Assembly 

FASM - Flat assembler (compile ASM to .exe)

FASM is a useful tool because it allows you to compile assembly to exe, using .asm source files. It's essentially standalone, but you do need to download the correct version first ( https://flatassembler.net/download.php )

FASM is interesting because you can put it on a USB or package it into another program, to compile new assembly from it - as long as the OS version matches up, you can compile on the fly without any setup needed.




To show you an example, I will create Hello World, in assembly - compiling with FASM:
Code
format PE console
entry start

include 'C:\Path\To\fasm\INCLUDE\win32a.inc'

section 'text' code readable executable

; Entry point
start:
    cinvoke printf, msg
    cinvoke ExitProcess, 0

section 'data' data readable writeable
    msg db 'Hello, World!',0

section 'idata' import data readable writeable

library kernel32, 'KERNEL32.DLL',\
        msvcrt, 'MSVCRT.DLL'

import kernel32,\
       ExitProcess, 'ExitProcess'

import msvcrt,\
       printf, 'printf'

Just compile like so:
Code
fasm hello.asm

If you don't have fasm in your PATH variable you can do it like this:
Code
C:\Path\To\fasm\fasm.exe C:\Path\To\hello-world.asm

This will create hello-world.exe, a 2KB file.

I hope this helped you!
Great share and good start for those who would like to try out FASM in this community.
(Jun 15, 2024 05:37 PM)happygonutty Wrote:  Great share and good start for those who would like to try out FASM in this community.

yeah, hope it helps someone!
I went a little further, going on to turn the hello world PE into bytes to include in another asm file, but I stopped before completing and cut that out of this thread for now - if I finish, I'll post in another thread (Assembly builder + scheduled process / runPE loader)
(Jun 15, 2024 06:51 PM)Hackers Wrote:  yeah, hope it helps someone!
I went a little further, going on to turn the hello world PE into bytes to include in another asm file, but I stopped before completing and cut that out of this thread for now - if I finish, I'll post in another thread (Assembly builder + scheduled process / runPE loader)

It will especially those who do not have an idea how assembly language works and how to compile. Using assembly language is quite tedious but FASM made it very easy and everything in the documentation is already sufficient. 🙃

Actually FASM and MASM are the only assembly languages that were very easy to use and comprehensive to read than any other. 🙃
(Jun 15, 2024 07:16 PM)happygonutty Wrote:  It will especially those who do not have an idea how assembly language works and how to compile. Using assembly language is quite tedious but FASM made it very easy and everything in the documentation is already sufficient. 🙃

Actually FASM and MASM are the only assembly languages that were very easy to use and comprehensive to read than any other. 🙃

Yeah I do think it is easier on Visual Studio - doing it this way with FASM here manually is not ideal. I should bring this over to VS & get the build instructions and includes sorted for easier development.
if you think vs is better then fasm you probably didnt work with it
from the first time i find it its the only compiler im using for 32x64 asm
the things you can do with fasm is endless the setup syntex macros debug etc
been using it for years so i know what im talking about also been trying masm and nasm which had also few good things for asm needs
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Jun 15, 2024 07:45 PM)Hackers Wrote:  Yeah I do think it is easier on Visual Studio - doing it this way with FASM here manually is not ideal. I should bring this over to VS & get the build instructions and includes sorted for easier development.

You can integrate FASM in VS? 🤯 I never knew that. I just plainly use the default FASM IDE. 🙃
(Jun 16, 2024 05:49 AM)happygonutty Wrote:  You can integrate FASM in VS? 🤯 I never knew that. I just plainly use the default FASM IDE. 🙃

Sorry, what I mean is that I should just go to Visual Studio, use MASM over there for ASM rather than doing this, but that's mostly because I do find it easier to get things done in VS. However, portable compilers are always useful I think so I wanted to share this thread here. I will check out the FASM IDE as I did this with command line calling my fasm path manually from my downloads folder lol. I probably should give it a better look so I can truly compare it to other solutions.
(Jun 16, 2024 07:14 AM)Hackers Wrote:  Sorry, what I mean is that I should just go to Visual Studio, use MASM over there for ASM rather than doing this, but that's mostly because I do find it easier to get things done in VS. However, portable compilers are always useful I think so I wanted to share this thread here. I will check out the FASM IDE as I did this with command line calling my fasm path manually from my downloads folder lol. I probably should give it a better look so I can truly compare it to other solutions.

Oh okay then. I was guessing that you maybe had a typo or something and was actually pertaining to MASM. Anyways, I prefer to do everything in one IDE or Editor rather than switching from time to time but I have this irritability that I have to use what the documentation said so or what the instruction is using kind of habit. 😆 OCD perhaps? 🤣
(Jun 16, 2024 04:47 PM)happygonutty Wrote:  Oh okay then. I was guessing that you maybe had a typo or something and was actually pertaining to MASM. Anyways, I prefer to do everything in one IDE or Editor rather than switching from time to time but I have this irritability that I have to use what the documentation said so or what the instruction is using kind of habit. 😆 OCD perhaps? 🤣

definitely depends on what you're doing, sometimes for certain setups it's better to just use whatever their documentation recommends even if you can do it another way. At least on a first run install, best to use whatever project tools & compiler makes the most sense. I don't really know enough about masm vs fasm to be honest


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Assembly] by TostigJan 22, 2023 03:35 PM 8 437 Jan 22, 2023 03:35 PM
Last Post: HFDone
[.NET] by hestemand123Feb 9, 2019 10:03 PM 1 193 Feb 9, 2019 10:03 PM
Last Post: StarZ
[Python] by White PartyhatSep 12, 2018 10:39 AM 8 278 Sep 12, 2018 10:39 AM
Last Post: silenceMeNow