inital-commit

This commit is contained in:
PoliEcho 2025-07-07 11:37:59 +02:00
commit aa86683b35
4 changed files with 57 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.asm-lsp.toml

29
Makefile Normal file
View File

@ -0,0 +1,29 @@
NASM = nasm
LD = ld
NASM_FLAGS := -felf64
LD_FLAGS := --strip-all
SRC_PATH := src
OBJ_PATH := build/obj
BIN_PATH := build/bin
SRC_FILES := $(wildcard $(SRC_PATH)/*.asm)
OBJ_FILES := $(patsubst $(SRC_PATH)/%.asm,$(OBJ_PATH)/%.o,$(SRC_FILES))
all: make-build-dir $(BIN_PATH)/asm-game-of-life
make-build-dir:
mkdir -p $(OBJ_PATH)
mkdir -p $(BIN_PATH)
$(BIN_PATH)/asm-game-of-life: $(OBJ_FILES)
$(LD) $(LD_FLAGS) $^ -o $@
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.asm
$(NASM) $(NASM_FLAGS) $< -o $@
clean:
rm -fr build

3
src/main.asm Normal file
View File

@ -0,0 +1,3 @@
section .text
global _start

24
src/str.asm Normal file
View File

@ -0,0 +1,24 @@
SYS_WRITE equ 1
STDOUT equ 1
print_str: ; takes pointer to string in rdi and retuns in rax
push rsi
push rdx
mov rsi, rdi
mov rdx, 0
.count_loop:
cmp byte [rsi+rdx], 0
je .print
inc rdx
jmp .count_loop
.print:
mov rax, SYS_WRITE
mov rdi, STDOUT
syscall
pop rdx
pop rsi
ret