From 78c4d3d06d8e863cfe2489281ccfe206544cbd7f Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 6 Sep 2026 00:40:37 +0200 Subject: fix: add utilities --- aoc-2025/utils/parse.asm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 aoc-2025/utils/parse.asm (limited to 'aoc-2025/utils/parse.asm') diff --git a/aoc-2025/utils/parse.asm b/aoc-2025/utils/parse.asm new file mode 100644 index 0000000..833cb4e --- /dev/null +++ b/aoc-2025/utils/parse.asm @@ -0,0 +1,22 @@ +; utils/parse.asm - decimal parsing helper. + +section .text + +; parse_u64: read decimal digits at [RSI] into RAX, advancing RSI past them. +; Stops on the first non-digit. Clobbers RAX, RDX. +parse_u64: + xor rax, rax +.digit: + mov dl, [rsi] + cmp dl, '0' + jl .done + cmp dl, '9' + jg .done + sub dl, '0' + movzx rdx, dl + imul rax, rax, 10 + add rax, rdx + inc rsi + jmp .digit +.done: + ret -- cgit v1.3