home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / cephes22 / qfloat / subm.asm < prev   
Assembly Source File  |  1992-11-17  |  3KB  |  268 lines

  1. ;    Static Name Aliases
  2. ;
  3.     TITLE   subm
  4.  
  5. include    qhead.asm
  6.  
  7. ;_TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  8. ;_TEXT    ENDS
  9. ;CONST    SEGMENT  WORD PUBLIC 'CONST'
  10. ;CONST    ENDS
  11. ;_BSS    SEGMENT  WORD PUBLIC 'BSS'
  12. ;_BSS    ENDS
  13. ;_DATA    SEGMENT  WORD PUBLIC 'DATA'
  14. ;_DATA    ENDS
  15. ;DGROUP    GROUP    CONST,    _BSS,    _DATA
  16. ;    ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  17.  
  18. PUBLIC  _subm, _addm, _shdn1, _shup1, _shdn8, _shup8, _shdn16, _shup16    
  19.  
  20. ;_DATA    SEGMENT
  21. ;EXTRN    __chkstk:NEAR
  22. ;_DATA    ENDS
  23.  
  24. _TEXT      SEGMENT
  25.  
  26. ; number of 16 bit words in mantissa area:
  27. ;OMG = 10
  28. ; offset to last word of mantissa area = 2*OMG+2:
  29. ;OFFS = 22
  30.  
  31. ; Subtract mantissa of x from mantissa of y, result to y
  32. ; subm( x, y )
  33.     PUBLIC    _subm
  34. _subm    PROC NEAR
  35.     push    bp
  36.     mov    bp,sp
  37.     push    si
  38.  
  39.     mov    si,WORD PTR [bp+4]
  40.     mov    bx,WORD PTR [bp+6]
  41.     clc
  42.  
  43. i=NQ+NQ
  44. REPT OMG+1
  45.     mov    dx,i[bx]
  46.     sbb    dx,i[si]
  47.     mov    i[bx],dx
  48. i=i-2
  49. ENDM
  50.     pop    si
  51.     pop    bp
  52.     ret    
  53. _subm    ENDP
  54.  
  55.  
  56.  
  57. ; add mantissa of x to mantissa of y, result to y
  58. ; addm( x, y );
  59.     PUBLIC    _addm
  60. _addm    PROC NEAR
  61.     push    bp
  62.     mov    bp,sp
  63.     push    si
  64.  
  65.     mov    si,[bp+4]
  66.     mov    bx,[bp+6]
  67.     clc
  68.  
  69. i=NQ+NQ
  70. REPT OMG+1
  71.     mov    dx,i[bx]
  72.     adc    dx,i[si]
  73.     mov    i[bx],dx
  74. i=i-2
  75. ENDM
  76.     pop    si
  77.     pop    bp
  78.     ret    
  79. _addm    ENDP
  80.  
  81.  
  82. ; shift mantissa of x down 1 bit
  83. ; shdn1(x);
  84.     PUBLIC    _shdn1
  85. _shdn1    PROC NEAR
  86.     push    bp
  87.     mov    bp,sp
  88.  
  89.     mov    bx,[bp+4]
  90.     clc
  91.  
  92. i=4
  93. REPT OMG+1
  94.     rcr    WORD PTR i[bx],1
  95. i=i+2
  96. ENDM
  97.     pop    bp
  98.     ret    
  99. _shdn1    ENDP
  100.  
  101.  
  102.  
  103. ; shift mantissa of x up 1 bit
  104. ; shup1(x);
  105.     PUBLIC    _shup1
  106. _shup1    PROC NEAR
  107.     push    bp
  108.     mov    bp,sp
  109.  
  110.     mov    bx,[bp+4]
  111.     clc
  112.  
  113. i=NQ+NQ
  114. REPT OMG+1
  115.     rcl    WORD PTR i[bx],1
  116. i=i-2
  117. ENDM
  118.     pop    bp
  119.     ret    
  120. _shup1    ENDP
  121.  
  122.  
  123.  
  124. ; shift mantissa of x down 8 bits
  125. ; shdn8(x);
  126.     PUBLIC    _shdn8
  127. _shdn8    PROC NEAR
  128.     push    bp
  129.     mov    bp,sp
  130.  
  131.     mov    bx,[bp+4]
  132.     sub    dx,dx
  133. i=4
  134. REPT OMG+1
  135.     mov    ax,WORD PTR i[bx]
  136.     xchg    al,ah
  137.     xchg    ah,dl
  138.     mov    WORD PTR i[bx],ax
  139. i=i+2
  140. ENDM
  141.     pop    bp
  142.     ret    
  143. _shdn8    ENDP
  144.  
  145.  
  146.  
  147. ; shift mantissa of x up 8 bits
  148. ; shup8(x);
  149.     PUBLIC    _shup8
  150. _shup8    PROC NEAR
  151.     push    bp
  152.     mov    bp,sp
  153.  
  154.     mov    bx,[bp+4]
  155.     sub    dx,dx
  156. i=NQ+NQ
  157. REPT OMG+1
  158.     mov    ax,WORD PTR i[bx]
  159.     xchg    al,ah
  160.     xchg    al,dl
  161.     mov    WORD PTR i[bx],ax
  162. i=i-2
  163. ENDM
  164.     pop    bp
  165.     ret    
  166. _shup8    ENDP
  167.  
  168.  
  169.  
  170. ; shift mantissa of x down 16 bits
  171. ; shdn16(x);
  172.     PUBLIC    _shdn16
  173. _shdn16    PROC NEAR
  174.     push    bp
  175.     mov    bp,sp
  176.  
  177.     mov    bx,[bp+4]
  178.     sub    dx,dx
  179. i=4
  180. REPT OMG+1
  181.     mov    ax,WORD PTR i[bx]
  182.     xchg    ax,dx
  183.     mov    WORD PTR i[bx],ax
  184. i=i+2
  185. ENDM
  186.     pop    bp
  187.     ret    
  188. _shdn16    ENDP
  189.  
  190.  
  191. ; shift mantissa of x up 16 bits
  192. ; shup16(x);
  193.     PUBLIC    _shup16
  194. _shup16    PROC NEAR
  195.     push    bp
  196.     mov    bp,sp
  197.  
  198.     mov    bx,[bp+4]
  199.     sub    dx,dx
  200. i=NQ+NQ
  201. REPT OMG+1
  202.     mov    ax,WORD PTR i[bx]
  203.     xchg    ax,dx
  204.     mov    WORD PTR i[bx],ax
  205. i=i-2
  206. ENDM
  207.     pop    bp
  208.     ret    
  209. _shup16    ENDP
  210.  
  211.  
  212.  
  213.  
  214. ; qmov(a,b)
  215. ; copy q type number from a to b
  216.  
  217.     PUBLIC _qmov
  218. _qmov    PROC NEAR
  219.     push    bp
  220.     mov    bp,sp
  221.     push    si
  222.     push    di
  223.     push    cx
  224.  
  225.     mov    si, word ptr [bp]+4
  226.     mov    di, word ptr [bp]+6
  227.     mov    cx, NQ
  228.     rep    movsw
  229.  
  230.     pop    cx
  231.     pop    di
  232.     pop    si
  233.     pop    bp
  234.     ret
  235. _qmov    ENDP
  236.  
  237.  
  238.  
  239.  
  240. ; qmovz(a,b)
  241. ; copy q type number from a to b
  242. ; and clear the bottom guard word of b
  243.  
  244.     PUBLIC _qmovz
  245. _qmovz    PROC NEAR
  246.     push    bp
  247.     mov    bp,sp
  248.     push    si
  249.     push    di
  250.     push    cx
  251.  
  252.     mov    si, word ptr [bp]+4
  253.     mov    di, word ptr [bp]+6
  254.     mov    cx, NQ
  255.     rep    movsw
  256.  
  257.     mov    word ptr [di],0
  258.  
  259.     pop    cx
  260.     pop    di
  261.     pop    si
  262.     pop    bp
  263.     ret
  264. _qmovz    ENDP
  265.  
  266. _TEXT    ENDS
  267. END
  268.