Created
May 27, 2011 20:23
-
-
Save jevinskie/996091 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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