Created
November 13, 2022 22:28
-
-
Save zeroflag/68cab6f9aae9c07a4b4e199d122a31c6 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
: hexchr>n ( chr -- n ) | |
48 over 57 between? if 48 - exit then | |
65 over 70 between? if 55 - exit then | |
97 over 102 between? if 87 - exit then | |
-1 ; | |
: hexstr>n ( adr len -- n ) | |
0 >r | |
begin | |
dup 0 > | |
while | |
1 - ( len ) | |
r> 4 lshift >r ( acc ) | |
over c@ hexchr>n ( digit ) | |
r> + >r ( acc ) | |
swap 1 + swap ( address ) | |
repeat | |
2drop r> ; | |
: 0x ( <word> -- n ) word hexstr>n ; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment