Ответ:
hex2bcd:
;hex to bcd conversion input r1:r2:r3:r4,output r2:r3:r4:r5
push xl
push xh
push yh
push yl
clr xl
clr xh
clr yl
clr yh
ldi r17,32
mov r5,r17
clr r17
hex2bcd_loop:
rol r4
rol r3
rol r2
rol r1
rol yh
rol yl
rol xh
rol xl
dec r5
brne hex2bcd1
mov r2,xl
mov r3,xh
mov r4,yl
mov r5,yh
pop yh
pop yl
pop xh
pop xl
ret
hex2bcd1:
subi xl,-3
sbrs xl,3
subi xl,3
subi xl,-0x30
sbrs xl,7
subi xl,0x30
subi xh,-3
sbrs xh,3
subi xh,3
subi xh,-0x30
sbrs xh,7
subi xh,0x30
subi yl,-3
sbrs yl,3
subi yl,3
subi yl,-0x30
sbrs yl,7
subi yl,0x30
subi yh,-3
sbrs yh,3
subi yh,3
subi yh,-0x30
sbrs yh,7
subi yh,0x30
rjmp hex2bcd_loop