; Description:
; Convert Value In Acc From Hex To BCD.
;
; Entry Requirements:
; Acc Has Value In Binary To Convert To BCD
;
; On Exit:
; Acc Has Entry Value Converted To BCD
;
; Affected:
; PSW.CY, PSW.Z, PSW.P, Acc
;
; Stack:
; 1 Bytes, Not Including Space Used By Called Routines
;
; Comments:
; Values Greater Than 99 Will Not Work Properly.
;
UTIL_BINTOBCD:
push b ; Save B
mov b,#10 ; Divide By 10
div ab ; Do Divide
swap a ; Move Result To High Of A
orl a,b ; OR In Remainder
pop b ; Recover B
ret ; Return To Caller
Source: Assorted Utilities, John C. Wren 11/23/96
Related topics:
8051 Program - convert 12bit binary to bcd | 8051 Program - convert dptr to signed string | 8051 Program - convert dptr to unsigned string | 8051 Program - memory subroutines | 8051 Program - math subroutines | 8051 Program - conversion subroutines
List of topics: 8051
No comments:
Post a Comment