; From Regulus Berdin; untested ; Input - ASCII number in W ; Output - binary in W ;*** WARNING: Manual replacement required for "SUBLW k" instruction (w = k - w). Check if previous instruction is a skip instruction. sublw '9' mov W, #'A' - 10 snb C mov W, #'0' mov W, ASCII-w
Tracy Smith says:
If you KNOW that the ASCII is '0'-'9','A'-'F' then a simpler solution for the midrange pics is:;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. ; addlw -'A' mov Hack, W mov W, #-'A' add W, Hack sb C ;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. ; addlw 'A' - 10 + '0' mov Hack, W mov W, #'A' - 10 + '0' add W, Hack ;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. ; addlw 10 mov Hack, W mov W, #10 add W, HackIf the ASCII value is in ram, then this solution will work for the 12 bit core too:
mov W, #-'A' snb ASCII.6 mov W, #-'0' add ASCII, W ;(or w)