home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d110 / pdc.lha / Pdc / src / lib.s < prev    next >
Text File  |  1987-10-28  |  2KB  |  64 lines

  1. *
  2. *       c_lmul  long signed multiply
  3. *
  4. *       multiplies two long operands on the stack and returns the
  5. *       result on the stack with no garbage.
  6. *
  7. *       Translated from the Unix version by J.A.Lydiatt 01Oct87.
  8. *
  9.         xdef    _c%lmul
  10. _c%lmul:
  11.         movem.l d0-d3,-(a7)     ;save registers
  12.         move.l  20(a7),d0       ;get parameter 1
  13.         move.w  d0,d2
  14.         move.w  d0,d1
  15.         ext.l   d1
  16.         swap    d1
  17.         swap    d0
  18.         sub.w   d0,d1
  19.         move.w  26(a7),d0       ;get msw of parameter 2
  20.         move.w  d0,d3
  21.         ext.l   d3
  22.         swap    d3
  23.         sub.l   24(a7),d3       ;subtract lsw of parameter 2
  24.         muls    d0,d1
  25.         muls    d2,d3
  26.         add.w   d1,d3
  27.         muls    d2,d0
  28.         swap    d0
  29.         sub.w   d3,d0
  30.         swap    d0
  31.         move.l  d0,24(a7)
  32.         move.l  16(a7),20(a7)   ;move return address
  33.         movem.l (a7)+,d0-d3     ;restore registers
  34.         addq.w  #4,a7           ;adjust stack
  35.         rts
  36. *
  37. *       _c%switch - execute c switch statement
  38. *
  39. *       the switch table is encoded as follows:
  40. *
  41. *               long    label1,case1
  42. *               long    label2,case2
  43. *               long    label3,case3
  44. *               ... for all cases
  45. *               long    0,defaultcase
  46. *
  47. *       the case variable is passed in d0
  48. *
  49.         xdef    _c%switch
  50. _c%switch:
  51.         move.l  (a7)+,a0        ;get table address
  52. c_sw1:
  53.         move.l  (a0)+,a1        ;get a label
  54.         move.l  a1,d1           ;test it for default
  55.         beq.s   c_sw2           ;jump if default case
  56.         cmp.l   (a0)+,d0        ;see if this case
  57.         bne.s   c_sw1           ;next case if not
  58.         jmp     (a1)            ;jump to case
  59. c_sw2:
  60.         move.l  (a0),a0         ;get default address
  61.         jmp     (a0)            ;jump to default case
  62.  
  63.         end
  64.