Search code examples
assemblymasm32irvine32

How to convert char to digit in Assembly Irvine?


I want to convert user's input character to digit(decimal) in Assembly MASM and Irvine library.

`CALL ReadChar ; store user input in AL register -> c ; user input character C

some code here to convert AL data to decimal 12

`


Solution

  • read the char
    subtract a '0' from it
    if after that, it's larger than 9,
    and it with 0xBF (to lowercase 'A'-'F' to 'a'-'f')
    and subtract 7 again.
    et voilá, there's your value