adventofcode2023/15/main_part1.s

45 lines
536 B
ArmAsm
Raw Normal View History

2023-12-15 01:58:12 -06:00
global _start
[bits 32]
[section .text]
%include "utils.s"
_start:
; HASH
mov esi, file
xor ebx, ebx ; current value
mov ebp, 17 ; mul value
hash:
movzx eax, byte [esi]
inc esi
cmp al, ','
jle .next_seq
; do HASH
; current += new
add eax, ebx
; current *= 17
mul ebp
; current %= 256
movzx ebx, al
jmp hash
.next_seq:
add [final_value], ebx
xor ebx, ebx
cmp esi, file.over
jb hash
game_over:
mov eax, [final_value]
call print_dec
call newline
jmp exit
[section .data]
final_value: dd 0
file: incbin "input"
.over:
[section .bss]