Monday, May 30, 2016

8051 Program - validate acc for ascii hex

; Description:
; Acc Contains An ASCII Value. Determine If Valid Hex Digit Or Not.
; If Not, Return Acc Trashed, And CY == 1. If Digit Is Valid, Return
; CY == 0.
;
; Entry Requirements:
; Acc Has ASCII Hex Value To Validate
;
; On Exit:
; CY == 0 If Acc = '0'..'9', 'a'..'f', 'A'..'F', CY == 1 If Not
;
; Affected:
; PSW.CY
;
; Stack:
; 2 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; None
;
UTIL_VALHXDG:
call UTIL_TOUPPER ; Make Upper Case
cjne a,#'0',loop1 ; If < '0', Return CY == 1
loop1:jc loop8 ;
cjne a,#'9',loop2 ; If <= '9', Return CY == 0
jmp loop7;
loop2:jc loop7;
cjne a,#'A',loop3 ; If < 'A', Return CY == 1
loop3:jc loop8 ;
cjne a,#'F',loop4 ; If > 'F', Return CY == 1
jmp loop5;
loop4:jnc loop8;
loop5:;
;
loop7:clr c ; CY == 0 Means Good Digit
ret ; Return To Caller
;
loop8:setb c ; CY == 1 Means Bad Digit
ret ; Return To Caller


Source: Assorted Utilities, John C. Wren 11/23/96



Related topics:
8051 Program - validate acc for ascii decimal   |   8051 Program - validate acc for A..Z, a..z, 0..9   |   8051 Program - validate string for A..Z, a..z, 0..9   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment