char2num local noLowerCase local convError local digit movwf temp sublw 'F' skipneg goto noLowerCase movlw 'a'-'A' subwf temp, f movlw temp noLowerCase ;test if the symbol i sless than '0': if sym - '0' >= 0 -> ok movlw '0' subwf temp, w ; temp - w skippz goto convError ; test if sym > 'F': if sym-'F'+1 >=0 -> error movlw 'F'+1 subwf temp, w skipneg goto convError movlw 'A' subwf temp, w skippz goto digit addlw 0x0A return digit movlw '0' subwf temp, w return convError movlw 0x00 return