Monday, May 30, 2016

8051 Program - convert binary to ascii

; Description:
; Convert Value In Low 4 Bits Of Acc To A Hex Digit
;
; Entry Requirements:
; Low 4 Bits Of Acc Have Value To Convert To '0'..'9', 'A'..'Z'
;
; On Exit:
; Value Of Low 4 Bits In ASCII
;
; Affected:
; PSW.CY, PSW.Z, PSW.P, Acc
;
; Stack:
; 0 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; Near Trick From A Z80 Book Circa 1982. Don't Know Who The Original
; Author Is.
;
UTIL_BINTOASC:
anl a,#00fh ; Keep Only Low Bits
add a,#090h ; Add 144
da a ; Decimal Adjust
addc a,#040h ; Add 64
da a ; Decimal Adjust
ret ; Return To Caller


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



Related topics:
8051 Program - convert base36 value to binary   |   8051 Program - convert binary to ascii base36   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment