From 22f1cae833b0a7892596be50bc1dbdb136778c51 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Tue, 7 Oct 2025 16:17:24 -0400 Subject: [PATCH] Hello, world! --- .gitignore | 1 + Makefile | 18 ++++++++++++++++++ README.md | 3 +++ helloworld.asm | 17 +++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 helloworld.asm diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b58f7a6 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +.PHONY: all clean + +SRC := $(wildcard *.asm) +OBJDIR := build +OBJS := $(SRC:%.asm=$(OBJDIR)/%.o) +BINS := $(SRC:%.asm=$(OBJDIR)/%) + +all: $(BINS) + +$(OBJDIR)/%: $(OBJDIR)/%.o + ld -m elf_i386 $< -o $@ + +$(OBJDIR)/%.o: %.asm + mkdir -p $(OBJDIR) + nasm -f elf $< -o $@ + +clean: + rm -rf $(OBJDIR) diff --git a/README.md b/README.md new file mode 100644 index 0000000..bb5df86 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# asm + +Build x86_64 assembly examples from [asmtutor.com](https://asmtutor.com) diff --git a/helloworld.asm b/helloworld.asm new file mode 100644 index 0000000..d43b234 --- /dev/null +++ b/helloworld.asm @@ -0,0 +1,17 @@ +; Hello World Program - asmtutor.com +; Compile with: nasm -f elf helloworld.asm +; Link with (64 bit systems require elf_i386 option): ld -m elf_i386 helloworld.o -o helloworld +; Run with: ./helloworld + +SECTION .data +msg db 'Hello World!', 0Ah ; assign msg variable with your message string + +SECTION .text +global _start + +_start: + mov edx, 13 ; number of bytes to write - one for each letter plus 0Ah (line feed character) + mov ecx, msg ; move the memory address of our message string into ecx + mov ebx, 1 ; write to the STDOUT file + mov eax, 4 ; invoke SYS_WRITE (kernel opcode 4) + int 80h