Monday, May 30, 2016

8051 Program - validate acc for ascii decimal

; Description:
; Acc Contains An ASCII Value. Determine If Valid Decimal DigitOr Not.
; If Not, Return Acc Trashed, And CY == 1. If Digit Is Valid, Return
; CY == 0.
;
; Entry Requirements:
; Acc Has ASCII Decimal Value To Validate
;
; On Exit:
; CY == 0 If Acc = '0'..'9', CY == 1 If Not
;
; Affected:
; PSW.CY
;
; Stack:
; 2 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; None
;
UTIL_VALDCDG:
call UTIL_TOUPPER ; Make Upper Case
cjne a,#'0',loop1 ; If < '0', Return CY == 1
loop1:jc loop3;
cjne a,#'9',loop2 ; If > '9', Return CY == 1
jmp val ;
loop2:jnc loop3;
val:clr c ; CY == 0 Means Good Digit
ret ; Return To Caller
;
loop3: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 hex   |   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