; Description:
; Convert ASCII Value In Acc To Binary. Checks Value To See That It's
; Legal Hex. If Not, Return CY == 1, Else Return Converted Value In
; Acc, And CY == 0.
;
; Entry Requirements:
; Acc Has Character To Convert From ASCII Hex To Binary
;
; On Exit:
; Acc Has Binary Value, Or Original Character If Not Legal ASCII Hex
;
; Affected:
; PSW.CY, PSW.Z, PSW.P, Acc
;
; Stack:
; 2 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; None
;
UTIL_HEXTOBIN:
call UTIL_VALHXDG ; See If Good Digit
jc loop3 ; If Not, Return CY == 1
subb a,#'0' ; Make 0..16 Range
cjne a,#9+1,loop1 ; See If <= 9
loop1: jc loop2 ; Return Value, It's In Range
subb a,#7 ; Make 00ah..00fh Range
loop2: clr c ; CY == 0 Means No Error
loop3: ret ; Return To Caller
Source: Assorted Utilities, John C. Wren 11/23/96
Related topics:
8051 Program - convert ascii decimal to binary | 8051 Program - convert bcd value to hex | 8051 Program - memory subroutines | 8051 Program - math subroutines | 8051 Program - conversion subroutines
List of topics: 8051
No comments:
Post a Comment