From 69a2f0a24cc7698bc49648d7419c3292140fc869 Mon Sep 17 00:00:00 2001 From: Jonas Hvid Date: Wed, 13 Nov 2019 21:53:45 +0100 Subject: [PATCH 1/1] Hello world in FASM --- .gitignore | 1 + Makefile | 6 ++++++ main.asm | 25 +++++++++++++++++++++++++ notes | 7 +++++++ 4 files changed, 39 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 main.asm create mode 100644 notes diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..95811e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/main diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..70cb7cd --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +main: main.asm + fasm $< $@ + +.PHONY: clean +clean: + rm -f main diff --git a/main.asm b/main.asm new file mode 100644 index 0000000..acb119a --- /dev/null +++ b/main.asm @@ -0,0 +1,25 @@ +format ELF64 executable + +struc with_length string& { + . db string + .length = $ - . +} + +macro write_stdout string_label { + mov rax, 1 + mov rdi, 1 + mov rsi, string_label + mov rdx, string_label#.length + syscall +} + +segment readable executable + +start: + write_stdout message + + jmp $ + +segment readable + +message with_length 'Hello, world!',$A diff --git a/notes b/notes new file mode 100644 index 0000000..c50b57b --- /dev/null +++ b/notes @@ -0,0 +1,7 @@ +FASM: +- https://flatassembler.net/docs.php?article=fasmg (Introduction) +- https://flatassembler.net/docs.php?article=fasmg_manual (Manual) +- https://flatassembler.net/docs.php?article=manual (Other manual) + +JONESFORTH: +- https://github.com/nornagon/jonesforth/blob/master/jonesforth.S -- 2.39.2