hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/aoc-2025/day3.asm
diff options
context:
space:
mode:
Diffstat (limited to 'aoc-2025/day3.asm')
-rw-r--r--aoc-2025/day3.asm69
1 files changed, 1 insertions, 68 deletions
diff --git a/aoc-2025/day3.asm b/aoc-2025/day3.asm
index c8b8b75..8330755 100644
--- a/aoc-2025/day3.asm
+++ b/aoc-2025/day3.asm
@@ -5,20 +5,11 @@ default rel
global _start
-%define SYS_EXIT 60
-%define SYS_READ 0
-%define SYS_WRITE 1
-%define SYS_OPEN 2
-%define SYS_CLOSE 3
-
-%define O_RDONLY 0
-%define STDOUT 1
+%include "utils/io.asm"
section .data
input_path db "input/day3.txt", 0
- newline db 10
-
label1 db "Part 1: ", 0
label2 db "Part 2: ", 0
@@ -31,7 +22,6 @@ section .bss
sum2 resq 1
work_digits resb 64 ; stack for greedy subsequence
- number_buffer resb 32 ; for printing
section .text
@@ -242,60 +232,3 @@ get_max_for_k:
jmp .convert_loop
.done:
ret
-
-print_newline:
- mov rax, SYS_WRITE
- mov rdi, STDOUT
- mov rsi, newline
- mov rdx, 1
- syscall
- ret
-
-print_int64:
- mov rdi, number_buffer+31
- mov byte [rdi], 0
- dec rdi
-
- cmp rax, 0
- jne .conv
-
- mov byte [rdi], '0'
- jmp .done
-.conv:
- mov rbx, 10
-.next:
- xor rdx, rdx
- div rbx
- add dl, '0'
- mov [rdi], dl
- dec rdi
- test rax, rax
- jnz .next
-
- inc rdi
-.done:
- mov rax, SYS_WRITE
- mov rsi, rdi
- mov rdi, STDOUT
- mov rdx, number_buffer+31
- sub rdx, rsi
- syscall
- ret
-
-print_string:
- push rcx
- push rdx
- mov rdx, 0
-.length:
- cmp byte [rcx+rdx], 0
- je .submit
- inc rdx
- jmp .length
-.submit:
- mov rax, SYS_WRITE
- mov rdi, STDOUT
- mov rsi, rcx
- syscall
- pop rdx
- pop rcx
- ret