adventofcode2023/18/main.s
2023-12-18 14:04:47 -06:00

66 lines
766 B
ArmAsm

%include "utils64.s"
global _start
[bits 64]
[section .text]
%define FILENAME "input"
;%define FILENAME "input_test"
_start:
mov rsi, file
mov rbp, 11_000_000_000 ; vert
mov rdi, 1 ; area
proc_line:
cmp rsi, file.over
jae .done
mov al, '#'
mov rcx, 32
xchg rdi, rsi
repne scasb
xchg rdi, rsi
call hex_parse
mov rbx, rax
and bl, 3
shr rax, 4
inc rsi ; \n
; process shit
cmp bl, 0
je .r
cmp bl, 1
je .d
cmp bl, 2
je .l
cmp bl, 3
je .u
.r:
add rdi, rax
mul rbp
add rdi, rax
jmp proc_line
.l:
mul rbp
sub rdi, rax
jmp proc_line
.d:
add rdi, rax
sub rbp, rax
jmp proc_line
.u:
add rbp, rax
jmp proc_line
.done:
hlt:
hlt ; go get a debugger, answer in rdi
jmp hlt
[section .data]
final_value: dq 0
file: incbin FILENAME
.over:
[section .bss]
[section .rodata]