inital-commit
This commit is contained in:
commit
aa86683b35
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.asm-lsp.toml
|
||||
29
Makefile
Normal file
29
Makefile
Normal 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
3
src/main.asm
Normal file
@ -0,0 +1,3 @@
|
||||
section .text
|
||||
global _start
|
||||
|
||||
24
src/str.asm
Normal file
24
src/str.asm
Normal 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user