home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / MAXONC3_6OF8.DMS / in.adf / LIBSRC.LHA / LIBSRC / math_pwr10.asm < prev    next >
Encoding:
Assembly Source File  |  1994-04-15  |  2.1 KB  |  138 lines

  1.  
  2. *    Maxon C++:
  3. *    Library "math_pwr10"
  4. *    Jens Gelhar 29.10.91, 15.04.94
  5.  
  6.     xdef    _pwr10,Pwr10
  7.     xdef    _expo10,Expo10
  8.  
  9.     xref    _MathIeeeDoubBasBase
  10.  
  11. i3edpMul    = -78
  12. i3edpDiv    = -84
  13.  
  14. _pwr10:    ; integer-Stackparameter
  15.     move.l    4(a7),d0
  16.     movem.l    d2-d3/a6,-(a7)
  17.     move.w    d0,d2
  18.     bsr.b    Pwr10
  19.     movem.l    (a7)+,d2-d3/a6
  20.     rts
  21.  
  22. Pwr10:    ; Potenz d2.w
  23.     move.l    _MathIeeeDoubBasBase,a6
  24.     tst.w    d2
  25.     bpl.b    lpwt1
  26.     neg.l    d2
  27.     cmp.w    #308,d2
  28.     bls.b    lpwt0
  29.     moveq    #0,d0       ; 10^d2 < MinReal
  30.     moveq    #0,d1
  31.     rts
  32. lpwt0    bsr.b    lpwt1
  33.     move.l    d0,d2
  34.     move.l    d1,d3
  35.     move.l    #$3FF00000,d0
  36.     moveq    #0,d1
  37.     jsr    i3edpDiv(a6)
  38.     rts
  39.  
  40. lpwt1    cmp.w    #308,d2
  41.     bhs.b    lpwt4
  42.     cmp.w    #10,d2
  43.     bls.b    lpwt2
  44.     move.w    d2,-(a7)
  45.     lsr.w    #1,d2
  46.     bsr.b    Pwr10
  47.     move.l    d0,d2
  48.     move.l    d1,d3
  49.     jsr    i3edpMul(a6)
  50.     move.w    (a7)+,d2
  51.     btst    #0,d2
  52.     beq.b    lpwt3
  53.     move.l    DoubPwr10tab+8(pc),d2
  54.     move.l    DoubPwr10tab+12(pc),d3
  55.     jmp    i3edpMul(a6)
  56. lpwt2    ; 0 <= d2 <= 10
  57.     asl.w    #3,d2
  58.     move.l    DoubPwr10tab(pc,d2.w),d0
  59.     move.l    DoubPwr10tab+4(pc,d2.w),d1
  60. lpwt3    rts
  61. lpwt4    moveq    #0,d0
  62.     move.l    d0,d1
  63.     rts
  64. DoubPwr10tab:
  65.     dc.l $3FF00000,0    ;    1
  66.     dc.l $40240000,0    ;   10
  67.     dc.l $40590000,0    ;  100
  68.     dc.l $408F4000,0    ; 1000
  69.     dc.l $40C38800,0    ; 10^4
  70.     dc.l $40F86A00,0    ; 10^5
  71.     dc.l $412E8480,0    ; 10^6
  72.     dc.l $416312D0,0    ; 10^7
  73.     dc.l $4197D784,0    ; 10^8
  74.     dc.l $41CDCD65,0    ; 10^9
  75.     dc.l $4202A05F,$20000000; 10^10
  76.  
  77.  
  78. _expo10:
  79.     movem.l    d2-d4/a6,-(a7)
  80.     movem.l    4*4+4(a7),d0/d1
  81.     bsr.b    Expo10
  82.     move.l    d4,d0
  83.     movem.l    (a7)+,d2-d4/a6
  84.     rts
  85.  
  86. Expo10:    ; von d0||d1 nach d4
  87.     moveq    #0,d4
  88.     bclr    #31,d0
  89.     cmp.l    #$000FFFFF,d0
  90.     bls.b    dexp9
  91.     movem.l    d0-d3/a0-a1,-(a7)
  92.     cmp.l    #$3FF00000,d0
  93.     bhs.b    dexp3
  94. dexp1    ; Zahl <1
  95.     subq.l    #1,d4
  96.     move.l    d4,d2
  97.     bsr    Pwr10
  98.     tst.l    d0
  99.     beq.b    dexp0
  100.     sub.l    (a7),d0
  101.     bhi.b    dexp1a
  102.     blo.b    dexp2
  103.     cmp.l    4(a7),d1
  104.     bls.b    dexp2
  105. dexp1a    cmp.l    #$01500000,d0   ; +21
  106.     bls.b    dexp1
  107.     subq.w    #5,d4
  108.     bra.b    dexp1
  109. dexp2    movem.l    (a7)+,d0-d3/a0-a1
  110.     rts
  111. dexp0    moveq    #0,d4
  112.     bra.b    dexp2
  113.  
  114. dexp3    ; Zahl >= 1
  115.     addq.l    #1,d4
  116.     cmp.w    #308,d4
  117.     bhs.b    dexp2
  118.     move.l    d4,d2
  119.     bsr    Pwr10
  120.     sub.l    (a7),d0
  121.     blo.b    dexp3a
  122.     bhi.b    dexp4
  123.     cmp.l    4(a7),d1
  124.     bhi.b    dexp4
  125. dexp3a    cmp.l    #$FED00000,d0  ; -20
  126.     bgt.b    dexp3
  127.     addq.w    #5,d4
  128.     cmp.l    #$FAF00000,d0  ; -80
  129.     bgt.b    dexp3
  130.     addq.w    #6,d4
  131.     bra.b    dexp3
  132. dexp4    subq.l    #1,d4
  133.     bra.b    dexp2
  134. dexp9    rts
  135.  
  136.     end
  137.  
  138.