Advertisement
glokyfull

spec divu 1992

Nov 16th, 2021
2,782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. ;
  3. ; division 32/16 a resultat sur 32 bit :  (x*65536)/y=bigQ
  4. ; d5.w dividende div 65536 (poid fort)     x
  5. ; d0.w diviseur y
  6. ;
  7. ;
  8. ; formule:
  9. ; bigQ=(x div y)*65536 +(x mod y)*(65536 div y)+
  10. ; ((65536 mod y)*(x mod y)) div y
  11. ;
  12. ; division non sign‚
  13.  
  14.  
  15.     ;move.w #124,d0 y
  16.     ;move.w #42,d1  x
  17.     ;jsr specialDiv ; 42*65536/124 = x*65536/y
  18.             ; resultat dans d4
  19.     ;illegal
  20.  
  21.     BSS
  22. SDr1    ds.w 1  ; (x mod y)
  23. SDq1    ds.w 1  ; (x div y)
  24. SDr2    ds.w 1  
  25. SDq2    ds.w 1
  26. ;.r2    ds.w 1  ; (65536 mod y)
  27.     TEXT
  28. specialDiv
  29.     moveq #0,d2
  30.     moveq #0,d3
  31.     move.w d0,d2    ;y
  32.     move.w d1,d3    ;x
  33.    
  34.     divu d2,d3      ; x div y -> d3
  35.     move.l d3,SDr1
  36.    
  37.    
  38.     moveq #1,d3
  39.     swap d3 ; d3 = 65536
  40.     divu d0,d3  ; / y
  41.     move.l d3,SDr2  ; stocke reste et quotient
  42.    
  43.    
  44.     moveq #0,d4
  45.     move.w SDq1,d4  ; (x div y)
  46.     swap d4     ; * 655536
  47.    
  48.     move.w SDq2,d5  ; (65536 div y)
  49.     mulu SDr1,d5    ; *(x mod y)
  50.     moveq #0,d6
  51.     move.w d5,d6
  52.     add.l d6,d4
  53.    
  54.     moveq #0,d5
  55.     move.w SDr2,d5
  56.     mulu SDr1,d5    ; (65536 mod y)*(x mod y)
  57.    
  58.     divu d0,d5      ; le tout sur y
  59.     moveq #0,d6
  60.     move.w d5,d6
  61.     add.l d6,d4
  62.    
  63.    
  64.         ;d4 = resultat
  65.     rts
  66.    
  67.  
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement