Monday, May 30, 2016

8051 Program - convert bcd value to hex

; Description:
; Convert BCD Value In Acc To Hex (i.e. 15h -> 00fh)
;
; Entry Requirements:
; Acc Has Value In BCD To Convert
;
; On Exit:
; Acc Has Entry Value Converted To Hex
;
; Affected:
; PSW.CY, PSW.Z, PSW.P, Acc
;
; Stack:
; 2 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; None
;
UTIL_BCDTOBIN:
push b ; Save B
push acc ; Save Value
anl a,#0f0h ; Keep High Bits
swap a ; Get To Low
mov b,#10 ; 10 Decimal
mul ab ; Multiply
mov b,a ; Store In B
pop acc ; Recover BCD Value
anl a,#00fh ; Keep Low Nybble
add a,b ; Add In High
pop b ; Recover B
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 ascii decimal to binary   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment