Код
lxi h,0x1234 ;BC = 0x1234
call bcd2bin
;BC = 0x4D2 (= 1234)
hlt
;BC = (H >> 4) * 1000 + (H & 0xF) * 100 + (L >> 4) * 10 + (L & 0xF)
bcd2bin
lxi b,0 ;BC = H >> 4
mov a,h
rrc
rrc
rrc
rrc
call add_al
call mul10 ;BC = BC * 10
mov a,h ;BC = BC + (H & 0xF)
call add_al
call mul10 ;BC = BC * 10
mov a,l ;BC = BC + (L >> 4)
rrc
rrc
rrc
rrc
call add_al
call mul10 ;BC = BC * 10
mov a,l ;BC = BC + (L & 0xF)
call add_al
ret
;BC = BC + (A & 0xF)
add_al
ani 0xF
add c
mov c,a
mvi a,0
adc b
mov b,a
ret
;BC = BC * 10
mul10
call shl
mov d,b
mov e,c
call shl
call shl
mov a,c
add e
mov c,a
mov a,b
adc d
mov b,a
ret
;BC = BC << 1
shl
ora a
mov a,c
ral
mov c,a
mov a,b
ral
mov b,a
ret