adventofcode2023/18/main.s

66 lines
766 B
ArmAsm
Raw Normal View History

2023-12-18 14:04:47 -06:00
%include "utils64.s"
2023-12-18 12:51:44 -06:00
global _start
2023-12-18 14:04:47 -06:00
[bits 64]
2023-12-18 12:51:44 -06:00
[section .text]
%define FILENAME "input"
;%define FILENAME "input_test"
_start:
2023-12-18 14:04:47 -06:00
mov rsi, file
mov rbp, 11_000_000_000 ; vert
mov rdi, 1 ; area
2023-12-18 12:51:44 -06:00
proc_line:
2023-12-18 14:04:47 -06:00
cmp rsi, file.over
2023-12-18 12:51:44 -06:00
jae .done
2023-12-18 14:04:47 -06:00
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
2023-12-18 12:51:44 -06:00
jmp proc_line
.done:
2023-12-18 14:04:47 -06:00
hlt:
hlt ; go get a debugger, answer in rdi
jmp hlt
2023-12-18 12:51:44 -06:00
[section .data]
2023-12-18 14:04:47 -06:00
final_value: dq 0
2023-12-18 12:51:44 -06:00
file: incbin FILENAME
.over:
[section .bss]
[section .rodata]