?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1.  ifndef included_xsqrt
  2.  define included_xsqrt
  3.  include "../common/mov.asm"
  4.  include "routines/srl64.asm"
  5.  include "sqrt/sqrt64.asm"
  6.  include "constantsx.asm"
  7.  
  8. var_c=xOP1   ;input
  9. var_y=var_c+4 ;  used for sqrt32
  10. var_x=xOP2   ;output
  11. var_b=xOP2   ; 4 bytes, result gets copied to bottom anyways
  12. var_a=xOP2   ;   2 bytes
  13. var_z0=xOP2+8;used in sqr32
  14.  
  15. xsqrt:
  16. ;HL points to x
  17. ;BC points to the output
  18. ;computes x^.5, if x>=0
  19. ;speed: 388+mov8+mov10+sqrt64+{0,7+srlxOP1_mantissa}
  20. ;min: 5456cc
  21. ;max: 7432cc
  22. ;avg: 6498.542cc
  23.  
  24.   push hl
  25.   push de
  26.   push bc
  27.   push af
  28.   push ix
  29.   push bc
  30.   call xsqrtpp;+_
  31.   ld hl,var_x
  32.   pop de
  33.   call mov8
  34.   ld hl,(xOP1+8)
  35.   ex de,hl
  36.   ld (hl),e
  37.   inc hl
  38.   ld (hl),d
  39.   pop ix
  40.   pop af
  41.   pop bc
  42.   pop de
  43.   pop hl
  44.   ret
  45. xsqrtpp;_:
  46.   ld de,xOP1
  47.   call mov10
  48.   ex de,hl
  49.   dec hl
  50.   ld a,(hl)
  51.   or a
  52.   jp m,sqrtNAN
  53.   ld d,a
  54.   dec hl
  55.   ld e,(hl)
  56.   or e
  57.   jp z,sqrt_special
  58.   ld a,d
  59.   add a,$40
  60.   rra
  61.   ld h,a
  62.   ld a,e
  63.   rra
  64.   ld l,a
  65.   ld (xOP1+8),hl
  66.   call nc,srlxOP1_mantissa
  67.   jp sqrt64   ;#include "../extended/sqrt/sqrt64.z80"
  68. sqrt_special:
  69. ;special case: 0 -> 0, NaN -> NaN, +inf -> +inf, so output=input
  70.   ld de,xOP1
  71.   ld hl,var_x
  72.   jp mov10
  73. sqrtNAN:
  74.   ld hl,xconst_NaN
  75.   ld de,xOP1
  76.   jp mov10
  77. ;#undefine var_b xOP2   ; 4 bytes, result gets copied to bottom anyways
  78. ;#undefine var_a xOP2   ;   2 bytes
  79. ;#undefine var_c xOP2+8 ;input
  80. ;#undefine var_y var_c+4 ;  used for sqrt32
  81. ;#undefine var_z0 xOP2+16
  82.  endif
  83.