AVR Assembler - Binary to BCD

AVR Assembler - Binary to BCD
.nolist .include "./m328Pdef.inc" .list .def temp = r16 .def v10k = r19 .def v1k = r20 .def v100 = r21 .def v10 = r22 .def v1 = r23 .org 0x00 rjmp reset reset: ldi temp, low(ramend) out spl, temp ldi temp, high(ramend) out sph, temp ldi zl, low(45678) ldi zh, high(45678) rcall bin2bcd loop: nop rjmp loop bin2bcd: ldi yl, 0x10 ; 10k ldi yh, 0x27 clr temp rcall m10k ret m10k: sub zl,yl sbc zh,yh brcs PC+3 inc temp rjmp m10k add zl, yl adc zh, yh mov v10k, temp ldi yl, 0xe8 ; 1k ldi yh, 0x03 clr temp rcall m1k ret m1k: sub zl,yl sbc zh,yh brcs PC+3 inc temp rjmp m1k add zl, yl adc zh, yh mov v1k, temp ldi yl, 0x64 ; 100 ldi yh, 0x00 clr temp rcall m100 ret m100: sub zl,yl sbc zh,yh brcs PC+3 inc temp rjmp m100 add zl, yl adc zh, yh mov v100, temp ldi yl, 0x0a ; 10 ldi yh, 0x00 clr temp rcall m10 ret m10: sub zl,yl sbc zh,yh brcs PC+3 inc temp rjmp m10 add zl, yl adc zh, yh mov v10, temp mov v1, zl ret /* add xl, yl adc xh, yh cp zl, xl cpc zh, xh brge done */