; Input - ASCII number in x ; Output - binary in x mov W, #-'A'+10 sb x.6 mov W, #-'0' add x, W
ASCII numbers '0'-'9' have codes 48-57, and 'A'-'F' have codes 65-70. The second group differs from the first one by a value of bit 6. To map '0'-'9' to 0-9 we need to substract '0' (if bit 6 is clear), and to map 'A'-'F' to 10-15 we substract 'A' and add 10 (if bit 6 is set).
Comments: