Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .macro hex str
- .local char, value, byteValue, digitPlace
- digitPlace .set 0
- byteValue .set 0
- .repeat .strlen( str ), i
- char .set .strat( str, i )
- .if char <> '_' .and char <> '''
- .if char >= 'a' && char <= 'f'
- value .set char - 'a' + 10
- .elseif char >= 'A' && char <= 'F'
- value .set char - 'A' + 10
- .elseif char >= '0' && char <= '9'
- value .set char - '0'
- .else
- .fatal .sprintf( "hex: Invalid character '%c' encountered", char )
- .endif
- byteValue .set byteValue | ( value << ( 4 * ( 1 - digitPlace ) ) )
- digitPlace .set digitPlace ^ 1
- .if digitPlace = 0
- .byte byteValue
- byteValue .set 0
- .endif
- .endif
- .endrepeat
- .if digitPlace = 1
- .fatal .sprintf( "hex: Number of digits must be a multiple of two" )
- .endif
- .endmacro
- hex "112''''23_34_4f'f"
- hex "09F9_1102_9D74E35BD84156C5635688C0"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement