home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / smart21b.zip / SAMPLES / SLINK / LINK.ASM < prev    next >
Assembly Source File  |  1991-11-19  |  2KB  |  116 lines

  1. ;************************************************************************
  2. .CODE
  3.  
  4.         PUBLIC    DIVIDE2
  5.         PUBLIC    STREET
  6.         PUBLIC    FINDS
  7.         PUBLIC    SETUP
  8.         PUBLIC    COPY4
  9.         PUBLIC    COPYEND
  10.  
  11.  
  12. ;************************************************************************
  13. DIVIDE2    PROC    NEAR
  14.         LLA_ENTRY
  15.  
  16.         mov    ax, parm2
  17.         mov    bx, parm1
  18.         imul    bx        ; m2 * m1
  19.         mov    si, 1
  20.         and    dx, dx
  21.         jns    smul_div_1
  22.         neg    si
  23. smul_div_1:
  24.         mov    bx, parm3
  25.         idiv    bx        ; m2 * m1 / d1
  26.         and    bx, bx        ; test if divisor is negative
  27.         jns    smul_div_2
  28.         neg    si
  29.         neg    bx        ; make it positive
  30. smul_div_2:
  31.         and    dx, dx        ; test if remainder is negative
  32.         jns    smul_div_3
  33.         neg    dx        ; make remainder positive
  34. smul_div_3:
  35.         shl    dx, 1        ; see if 2 * remainder is > divisor
  36.         cmp    dx, bx
  37.         jl    smul_div_4
  38.         add    ax, si
  39.  
  40. smul_div_4:
  41.         LLA_EXIT
  42. DIVIDE2    ENDP
  43.  
  44. ;************************************************************************
  45. STREET        PROC    NEAR
  46.         LLA_ENTRY
  47.  
  48.         mov    bx, parm1        ; pop low word of addr
  49.         mov    ax,ds            ; set hi word of addr
  50.  
  51.         LLA_EXIT
  52. STREET        ENDP
  53.  
  54.  
  55. ;************************************************************************
  56. FINDS        PROC    NEAR
  57.         LLA_ENTRY
  58.  
  59.         les    bx, dparm1
  60.         mov    ax, es:[bx]
  61.  
  62.         LLA_EXIT
  63. FINDS        ENDP
  64.  
  65.  
  66. ;************************************************************************
  67. SETUP        PROC    NEAR
  68.         LLA_ENTRY
  69.  
  70.         les    bx, dparm1
  71.         mov    ax, parm3
  72.         mov    es:[bx], ax
  73.  
  74.         LLA_EXIT
  75. SETUP        ENDP
  76.  
  77.  
  78. ;************************************************************************
  79. COPYEND        PROC    NEAR
  80.         LLA_ENTRY
  81.  
  82.         cld            ; assume forward
  83.         les    di, dparm1    ; dest off & seg
  84.         lds    si, dparm2    ; src off & seg
  85.         xor    cx, cx
  86.         xor    ah, ah
  87. lsc_loop:
  88.         lodsb
  89.         cmp    al, 0
  90.         je    lsc_done
  91.         inc    cx
  92.         stosb
  93.         JMPS    lsc_loop
  94. lsc_done:
  95.         stosb
  96.         mov    ax, cx
  97.  
  98.         LLA_EXIT
  99. COPYEND        ENDP
  100.  
  101.  
  102. ;************************************************************************
  103. COPY4        PROC    NEAR
  104.         LLA_ENTRY
  105.  
  106.         les    di, dparm1        ; dest off
  107.         lds    si, dparm2        ; src off
  108.         mov    cx, parm5        ; count
  109.         cld
  110.     rep    movsb
  111.  
  112.         LLA_EXIT
  113. COPY4        ENDP
  114.  
  115.         END
  116.