Skip to content

Instantly share code, notes, and snippets.

@remexre
Created November 1, 2018 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remexre/6541a8757d30c1c206066e44c9f9884c to your computer and use it in GitHub Desktop.
Save remexre/6541a8757d30c1c206066e44c9f9884c to your computer and use it in GitHub Desktop.
Miscellaneous assembly snippets
bits 64
global dehex
[section .text]
; unsigned char dehex(const char hex[2]);
dehex:
mov ax, [rdi]
sub ax, 12336
cmp ax, 2559
jl .L1
sub ax, 1792
.L1:
cmp al, 9
jle .L2
sub al, 7
.L2:
xchg ah, al
shl ah, 4
or al, ah
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment