Skip to content

Instantly share code, notes, and snippets.

@jevinskie
Created May 27, 2011 20:23
Show Gist options
  • Save jevinskie/996091 to your computer and use it in GitHub Desktop.
Save jevinskie/996091 to your computer and use it in GitHub Desktop.
hex2int-asm:
cpi r24, 'A'
brlo 0f
subi r24, 'A' - '0'
0:
subi r24, '0'
ret
hex2int-c:
cpi r24, 'A'
brsh 0f
subi r24, '0'
ret
0f:
subi r24, 'A' - 10
ret
uint8_t hex2int(uint8_t c)
{
if (c < 'A')
{
return c - '0';
}
else
{
return c - 'A' + 10;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment