Skip to content

Instantly share code, notes, and snippets.

@routevegetable
Created August 30, 2018 11:12
Show Gist options
  • Save routevegetable/16a3dd00f009b9ef7b2fa627a38b1f1d to your computer and use it in GitHub Desktop.
Save routevegetable/16a3dd00f009b9ef7b2fa627a38b1f1d to your computer and use it in GitHub Desktop.
// void print_hex(unsigned char num);
.data
buff:
.ascii "0x00\n"
.global print_hex
.text
print_hex:
mov %rdi,%rax
and $0x0F,%rax
add $0x30,%rax
cmp $0x3A,%rax
jl 1f
add $0x7,%rax
1:
mov %al,buff+3(%rip)
mov %rdi,%rax
shr $0x4,%rax
and $0x0F,%rax
add $0x30,%rax
cmp $0x3A,%rax
jl 1f
add $0x7,%rax
1:
mov %al,buff+2(%rip)
mov $0x1,%rdi
lea buff(%rip),%rsi
mov $0x5,%rdx
mov $0x1,%rax
syscall
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment