?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef included_xcis
  2. #define included_xcis
  3. #include "pushpop.z80"
  4. #include "xcos.z80"
  5. #include "xmul.z80"
  6. #include "xsqrt.z80"
  7. #include "xrsub.z80"
  8.  
  9. xcis:
  10. ;; Computes cosine and sine
  11. ;; Named after the reresentation, cis(x) = cos(x)+i*sin(x)
  12. ;; This is like exp(i*x), but we are computing it as:
  13. ;;   cos(x)+i*sqrt(1-cos(x)^2)
  14.   call pushpop
  15.  
  16. ;Compute cosine and store it back to BC
  17.   call xcos
  18.  
  19. ;Now we need to square this and store it to BC+10
  20.   ld h,b
  21.   ld l,c
  22.   ld d,b
  23.   ld e,c
  24.  
  25. ;Advance BC by 10
  26.   ld a,c
  27.   add a,10
  28.   ld c,a
  29.   jr nc,+_
  30.   inc b
  31. _:
  32.   call xmul
  33.  
  34.   ld de,xconst_1
  35.   ld h,b
  36.   ld l,c
  37.   call xrsub
  38.  
  39.   jp xsqrt
  40. #endif
  41.