Compare commits

...

4 Commits

Author SHA1 Message Date
5709c50700 testing 2025-10-10 22:16:15 -04:00
33175e2c19 Subroutines 2025-10-07 22:18:26 -04:00
5685ac6e67 Calculate string length 2025-10-07 20:29:32 -04:00
3360f1976c Proper program exit 2025-10-07 17:03:59 -04:00
3 changed files with 19 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
.PHONY: all clean .PHONY: all clean
SRC := $(wildcard *.asm) SRC := $(wildcard *.asm)
SRC := $(filter-out functions.asm, $(SRC))
OBJDIR := build OBJDIR := build
OBJS := $(SRC:%.asm=$(OBJDIR)/%.o) OBJS := $(SRC:%.asm=$(OBJDIR)/%.o)
BINS := $(SRC:%.asm=$(OBJDIR)/%) BINS := $(SRC:%.asm=$(OBJDIR)/%)

0
functions.asm Normal file
View File

View File

@@ -1,17 +1,22 @@
; Hello World Program - asmtutor.com ; %include 'functions.asm'
; 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 SYS_EXIT equ 1
msg db 'Hello World!', 0Ah ; assign msg variable with your message string SYS_WRITE equ 4
STDOUT equ 1
SECTION .text section .data
global _start msg db "Hello, world!", 0Ah
section .text
global _start
_start: _start:
mov edx, 13 ; number of bytes to write - one for each letter plus 0Ah (line feed character) mov edx, 14
mov ecx, msg ; move the memory address of our message string into ecx mov ecx, msg
mov ebx, 1 ; write to the STDOUT file mov ebx, STDOUT
mov eax, 4 ; invoke SYS_WRITE (kernel opcode 4) mov eax, SYS_WRITE
int 80h int 0x80
mov ebx, 0
mov eax, SYS_EXIT
int 0x80