Hello world in FASM
authorJonas Hvid <mail@johv.dk>
Wed, 13 Nov 2019 20:53:45 +0000 (21:53 +0100)
committerJonas Hvid <mail@johv.dk>
Wed, 13 Nov 2019 20:53:45 +0000 (21:53 +0100)
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
main.asm [new file with mode: 0644]
notes [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..95811e0
--- /dev/null
@@ -0,0 +1 @@
+/main
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
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 (file)
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 (file)
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