.func DivideLongLong DivideLongLong: ; Divide r22:r23:r24:r25 (L->H) by r18:r19:r20:r21 (L->H) ; Result r18:r19:r20:r21 ; Reminder r22:r23:r24:r25 ; Uses: r16, r18, r19, r20, r21, r22, r23 ; r24, r25, r26, r27, r30, r31 ; Preset ldi r16,0x21 ; Loop Counter clr r26 ; r26:r27 r30:r31 = 0 clr r27 movw r30,r26 rjmp DILoop1 DILoop0:rol r26 rol r27 rol r30 rol r31 cp r26,r18 cpc r27,r19 cpc r30,r20 cpc r31,r21 brcs DILoop1 sub r26,r18 sbc r27,r19 sbc r30,r20 sbc r31,r21 DILoop1:rol r22 rol r23 rol r24 rol r25 dec r16 brne DILoop0 ; Finalize com r22 com r23 com r24 com r25 movw r18,r22 ; Result r22:r23 ==> r18:r19 movw r20,r24 ; Result r24:r25 ==> r20:r21 movw r22,r26 ; Result r26:r27 ==> r22:r23 movw r24,r30 ; Result r30:r31 ==> r24:r25 ret .endfunc