Monday, May 30, 2016

8051 Program - convert ascii decimal to binary

; Description:
; Convert ASCII Value In Acc To Binary. Checks Value To See That It's
; Legal Decimal. If Not, Return CY == 1, Else Return Converted Value
; In Acc, And CY == 0.
;
; Entry Requirements:
; Acc Has Character To Convert From ASCII Decimal To Binary
;
; On Exit:
; Acc Has Binary Value, Or Original Character If Not Legal ASCII Decimal
;
; Affected:
; PSW.CY, PSW.Z, PSW.P, Acc
;
; Stack:
; 2 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; None
;
UTIL_DECTOBIN:
call UTIL_VALDCDG ; See If Good Digit
jc loop1 ; If Not, Return CY == 1
subb a,#'0' ; Make 0..9 Range
clr c ; CY == 0 Means No Error
loop1:ret ; Return To Caller


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



Related topics:
8051 Program - convert ascii hex 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