home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1998 February / PCOnline_02_1998.iso / filesbbs / os2 / pgp263.arj / PGP263I.SRC / PGP263II.ZIP / src / amiga_asm.a < prev    next >
Text File  |  1995-02-21  |  4KB  |  153 lines

  1. ; 68000.s for SAS/asm v6.x
  2. ; register parameters, small code/small data model
  3.  
  4.         SECTION code
  5.  
  6.         XREF    _global_precision
  7.  
  8. ; r1 = r1 + r2 + carry
  9. ; boolean P_ADDC(unitptr r1, unitptr r2, boolean carry)
  10. ; D0.B           A0          A1          D0.B
  11.  
  12.         XDEF    _P_ADDC
  13.         XDEF    @P_ADDC
  14. _P_ADDC:
  15.         move.l  4(SP),a0
  16.         move.l  8(SP),a1
  17.         move.l  12(SP),d0
  18. @P_ADDC:
  19.         move.l  d2,-(sp)
  20.         move.b  d0,d1
  21.         sne     d1
  22.         moveq.l #0,d2
  23.         move.w  _global_precision(a4),d2
  24.         asl.l   #2,d2
  25.         add.l   d2,a0
  26.         add.l   d2,a1
  27.         asr.l   #2,d2
  28.         subq.l  #1,d2
  29.         asr.b   #1,d1
  30. add_loop:
  31.         addx.l  -(a1),-(a0)
  32.         dbf     d2,add_loop
  33.         scs     d0
  34.         move.l  (sp)+,d2
  35.         rts
  36.  
  37. ; r1 = r1 - r2 - borrow
  38. ; boolean P_SUBB(unitptr r1, unitptr r2, boolean borrow)
  39. ; D0.B           A0          A1          D0.B
  40.  
  41.         XDEF    _P_SUBB
  42.         XDEF    @P_SUBB
  43. _P_SUBB:
  44.         move.l  4(SP),a0
  45.         move.l  8(SP),a1
  46.         move.l  12(SP),d0
  47. @P_SUBB:
  48.         move.l  d2,-(sp)
  49.         move.b  d0,d1
  50.         sne     d1
  51.         moveq.l #0,d2
  52.         move.w  _global_precision(a4),d2
  53.         asl.l   #2,d2
  54.         add.l   d2,a0
  55.         add.l   d2,a1
  56.         asr.l   #2,d2
  57.         subq.l  #1,d2
  58.         asr.b   #1,d1
  59. sub_loop:
  60.         subx.l  -(a1),-(a0)
  61.         dbf     d2,sub_loop
  62.         scs     d0
  63.         move.l  (sp)+,d2
  64.         rts
  65.  
  66. ; r1 = r1 << 1 | carry;
  67. ; boolean P_ROTL(unitptr r1, boolean carry)
  68. ; D0.B           A0          D0.B
  69.  
  70.         XDEF    _P_ROTL
  71.         XDEF    @P_ROTL
  72. _P_ROTL:
  73.         move.l  4(SP),a0
  74.         move.l  8(SP),d0
  75. @P_ROTL:
  76.         move.l  d2,-(sp)
  77.         move.b  d0,d1
  78.         sne     d1
  79.         moveq.l #0,d2
  80.         move.w  _global_precision(a4),d2
  81.         asl.l   #2,d2
  82.         add.l   d2,a0
  83.         asr.l   #1,d2
  84.         subq.l  #1,d2
  85.         asr.b   #1,d1
  86. rol_loop:
  87.         roxl.w  -(a0)
  88.         dbf     d2,rol_loop
  89.         scs     d0
  90.         move.l  (sp)+,d2
  91.         rts
  92.  
  93.         XDEF    _P_SETP
  94.         XDEF    @P_SETP
  95. _P_SETP:
  96. @P_SETP:
  97.         rts
  98.  
  99.  
  100. ;********************************************************************
  101. ; P_SMUL copied from the sun3 mc68020.s and modified RKNOP 940612
  102. ;  P_SMUL(*a,*b,x) performs a+=b*x.  Pointers are to LSB despite
  103. ;                                     Motorola byte ordering
  104. ;********************************************************************
  105.  
  106.         IFD _M68020
  107.  
  108.                 XDEF     _P_SMUL
  109.                 XDEF     @P_SMUL
  110.  
  111. _P_SMUL:
  112.                 move.l  4(SP),a0
  113.                 move.l  8(SP),a1
  114.                 move.l  12(SP),d0
  115. @P_SMUL:
  116.                 tst.l   d0                      ; test to speed multiplies by 0
  117.                 beq.b   .exit
  118.  
  119.                 movem.l d2-d5,-(sp)             ;Save registers
  120.  
  121.                 move.l  d0,d1                   ; &a in a0, &b in a1, x in d0
  122.                 move.w  _global_precision(a4),d5 ;longword count
  123.  
  124.                 subq.w  #2,d5                   ; first longword not handled in loop
  125.                 clr.l   d4                      ; Clear d4 so we have a 0 for adding X-bit later
  126.  
  127.                 move.l  (a1),d2                 ; d2 has lower byte of product
  128.                 mulu.l  d1,d3:d2                ; d3 has carry (high byte of product)
  129.                 add.l   d2,(a0)                 ; accumulate
  130.  
  131.                 tst.w   d5                      ;This code is needed if global_precision<2
  132.                 blt.b   .SMUL2                  ; only one longword?
  133.  
  134. .SMUL1          move.l  -(a0),d0                ; Predecrement 'cause a0 started pointing at LSB
  135.                 addx.l  d3,d0                   ; accumulate carry and X-bit
  136.                 move.l  -(a1),d2
  137.                 mulu.l  d1,d3:d2
  138.                 addx.l  d4,d3                   ;add X-bit to carry
  139.                 add.l   d2,d0                   ;accumulate
  140.                 move.l  d0,(a0)
  141.                 dbf     d5,.SMUL1               ;loop until ((--d5)==-1)
  142.  
  143. .SMUL2          addx.l  d4,d3                   ; add X-bit to carry
  144.                 move.l  d3,-(a0)                ; And put that in the highest byte of (a0)
  145.  
  146.                 movem.l (sp)+,d2-d5             ;restore registers saved earlier
  147. .exit           rts
  148.  
  149.  
  150.         ENDC ; _M68020
  151.  
  152.         END
  153.