?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1.  ifndef included_div64
  2.  define included_div64
  3.  include "div64_32.asm"
  4.  include "../mul/mul32.asm"
  5.  include "../routines/add64.asm"
  6.  include "../routines/sub64.asm"
  7.  
  8. var_x=xOP2   ;output
  9. div64:
  10. ;var_n / var_x
  11. ;304+2*div64_32+mul32+sub64+{0,72+add64+{0,19+{0,19+{0,3
  12. ;304+2*div64_32+mul32+sub64+169.0607843
  13. ;2*div64_32+3128.7937843
  14. ;
  15. ;304+2*div64_32+mul32+sub64+{0,72+add64+{0,19+{0,19+{0,3
  16. ;min: 6683cc
  17. ;max: 11469cc
  18. ;avg: 9759.520cc
  19.   call div64_32
  20.   ld (var_q+4),ix
  21.   ld (var_q+6),bc
  22. ;Need to adjust the remainder
  23.   ld (var_n+6),hl
  24.   ld (var_n+4),de
  25.   ld hl,(var_x)
  26.   ld de,(var_x+2)
  27.   call mul32  ;DEHL * BCIX
  28.   ;var_z0 holds the 64-bit result
  29.   ;need var_n-z0_32
  30.   ld hl,0
  31.   ld (var_n),hl
  32.   ld (var_n+2),hl
  33.   ld de,var_n
  34.   ld hl,z0_32
  35.   call sub64
  36.   jr nc,div64_end
  37. div64_recarry:
  38.   ld de,var_n
  39.   ld hl,var_x
  40.   call add64
  41.   push af
  42.   ld hl,var_q+4
  43.   ld a,-1
  44.   dec (hl) : cp (hl) : jr nz,div64_decq;+_
  45.   inc hl : dec (hl) : cp (hl) : jr nz,div64_decq;+_
  46.   inc hl : dec (hl) : cp (hl) : jr nz,div64_decq;+_
  47.   inc hl : dec (hl)
  48. div64_decq;_:
  49.   pop af
  50.   jr nc,div64_recarry
  51. div64_end:
  52.   call div64_32
  53.   ld (var_q),ix
  54.   ld (var_q+2),bc
  55.   ret
  56.  endif
  57.