1: ldfps = 170100^tst
   2: stfps = 170200^tst
   3: /
   4: /	sqrt replaces the f.p. number in fr0 by its
   5: /	square root.  newton's method
   6: /
   7: .globl  sqrt, _sqrt
   8: /
   9: /
  10: _sqrt:
  11:         mov     r5,-(sp)
  12:         mov     sp,r5
  13:         movf    4(r5),fr0
  14:         jsr     pc,sqrt
  15:         mov     (sp)+,r5
  16:         rts     pc
  17: 
  18: sqrt:
  19:         tstf    fr0
  20:         cfcc
  21:         bne     1f
  22:         clc
  23:         rts     pc              /sqrt(0)
  24: 1:
  25:         bgt     1f
  26:         clrf    fr0
  27:         sec
  28:         rts     pc              / sqrt(-a)
  29: 1:
  30:         mov     r0,-(sp)
  31:         stfps   -(sp)
  32:         mov     (sp),r0
  33:         bic     $!200,r0                / retain mode
  34:         ldfps   r0
  35:         movf    fr1,-(sp)
  36:         movf    fr2,-(sp)
  37: /
  38:         movf    fr0,fr1
  39:         movf    fr0,-(sp)
  40:         asr     (sp)
  41:         add     $20100,(sp)
  42:         movf    (sp)+,fr0       /initial guess
  43:         mov     $4,r0
  44: 1:
  45:         movf    fr1,fr2
  46:         divf    fr0,fr2
  47:         addf    fr2,fr0
  48:         mulf    $half,fr0       / x = (x+a/x)/2
  49:         sob     r0,1b
  50: 2:
  51:         movf    (sp)+,fr2
  52:         movf    (sp)+,fr1
  53:         ldfps   (sp)+
  54:         mov     (sp)+,r0
  55:         clc
  56:         rts     pc
  57: /
  58: half    = 40000

Defined functions

_sqrt declared in line 7; defined in line 10; used 1 times
  • in line 7
half defined in line 58; used 1 times
  • in line 48
sqrt declared in line 7; defined in line 18; used 9 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 548
Valid CSS Valid XHTML 1.0 Strict