;*************************************
; [r4:r0]/[r7:r5]---->r4:r0___r10:r8
; 40bit/24bit
; if r7:r5=0 output=9999999

divu: 
        mov     r8,r7
        or      r8,r6
        or      r8,r5
        brne    divu0

        ldi     r16,0
        mov     r3,r16  
        ldi     r16,0x98
        mov     r2,r16          
        ldi     r16,0x96
        mov     r1,r16  
        ldi     r16,0x7F
        mov     r0,r16  
        ret
divu0: 
        clr     r8            
      	clr     r9            
        clr     r10                 
        ldi     N,40
divu1:                                     
        lsl     r0           
        rol     r1           
        rol     r2           
        rol     r3
	rol	r4           
        rol     r8       
        rol     r9            
        rol     r10                        
        cp      r8,r5      
        cpc     r9,r6      
        cpc     r10,r7            
        brcs    divu2    
        inc     r0           
        sub     r8,r5      
        sbc     r9,r6     
        sbc     r10,r7            
 divu2:
        dec     N      
        brne   	divu1
	
	lsl	r8	;四捨五入
	rol	r9
	rol	r10
	brcs	divu3
	cp	r8,r5 
	cpc	r9,r6 
	cpc	r10,r7
	brmi	divu4
divu3:
	clr	r11
	sec
	adc	r0,r11
	adc	r1,r11
	adc	r2,r11
	adc	r3,r11
	adc	r4,r11
divu4:
        ret 