How to check if a char is a digit or not?
In C, I would write this:
char c1 = '3';
if ((c1 >= 65) && (c1 <= 122)) printf("Digit");

The problem is I don't know how to convert the char into ASCII. Any idea?
Posted on 2011-04-19 22:53:26 by anta40
To convert a numeric digit from ASCII you just subtract from 30h.

sub al, 30h ; convert from '0' to 0
Posted on 2011-04-20 00:23:44 by Synfire

c1 db '3',0

if ((c1 >= '1') && (c1 <= '0'))

Posted on 2011-04-20 08:03:02 by JimmyClif
Actually you don't 'convert' anything in asm (at least not in C terminology). Everything is just numbers. ASCII chars are int the range 32-127.
Posted on 2011-04-20 13:47:49 by ti_mo_n
I am not quite sure what the problem is.

Why would you want to do some conversion when Char and ASCII are actually the same thing?
They are just fancy names for an 8-bit (1-byte) size value.

Can you tell us what exactly are you trying to do so that we can understand the proper solution?

Is it trying to do that value comparison you have on C into Assembly? Or is it converting a value to another?
Posted on 2011-05-17 13:00:30 by banzemanga
Are you trying to do this so you can decide whether you can perform numerical computations or are you just trying to see if the field contains a valid numerical character?
Posted on 2011-07-23 19:41:30 by green