summary refs log tree commit diff homepage
path: root/lib.asm
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2016-12-02 04:58:57 -0500
committerJune McEnroe <june@causal.agency>2016-12-02 04:58:57 -0500
commit5c3858a91442a331866049802fa57381e5cbb1ee (patch)
treee08b59b1e842f2bd948626c87624cee71c2d2e7f /lib.asm
parentRewrite day 1 solution (diff)
downloadaoc-5c3858a91442a331866049802fa57381e5cbb1ee.tar.gz
aoc-5c3858a91442a331866049802fa57381e5cbb1ee.zip
Add 32-bit hex formatting
Diffstat (limited to '')
-rw-r--r--lib.asm19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib.asm b/lib.asm
new file mode 100644
index 0000000..10d0e1c
--- /dev/null
+++ b/lib.asm
@@ -0,0 +1,19 @@
+section .rodata
+hexDigits: db '0123456789ABCDEF'
+
+section .text
+hex32:
+  push rbx
+  mov rbx, hexDigits
+  xor rax, rax
+
+%rep 8
+  shl rax, 8
+  mov al, dil
+  and al, 0x0F
+  xlatb
+  shr rdi, 4
+%endrep
+
+  pop rbx
+ret