home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / packetdrivers.tar.gz / pd.tar / src / multicrc.asm < prev    next >
Assembly Source File  |  1995-06-25  |  2KB  |  92 lines

  1.     public    set_multicast_list
  2. set_multicast_list:
  3. ;enter with ds:si ->list of multicast addresses, ax = number of addresses,
  4. ;  cx = number of bytes.
  5. ;return nc if we set all of them, or cy,dh=error if we didn't.
  6.     assume ds:code
  7.  
  8.     mov    cx,ax            ;keep a count of addresses in cx.
  9.     mov    di,offset mcast_list_bits
  10.     xor    ax,ax
  11.     mov    [di+0],ax
  12.     mov    [di+2],ax
  13.     mov    [di+4],ax
  14.     mov    [di+6],ax
  15.     jcxz    set_mcl_2
  16. set_mcl_1:
  17.     call    add_mc_bits
  18.     loop    set_mcl_1
  19. set_mcl_2:
  20.     call    set_hw_multi    ; Set the multicast mask bits in chip
  21.     clc
  22.     ret
  23.  
  24. add_mc_bits:
  25. ;entry:    ds:si -> multicast address, di-> sixty-four bit multicast filter.
  26. ;preserve cx, di, increment si by EADDR_LEN
  27.     push    cx
  28.     mov    cx,EADDR_LEN
  29.     mov    dx,0ffffh            ; this is msw.
  30.     mov    bx,0ffffh            ; set 32 bit number
  31. add_mcb_1:
  32.     lodsb
  33.     call    upd_crc            ; update crc
  34.     loop    add_mcb_1        ; and loop.
  35.  
  36.   ifdef MULTICRC_REVERSE
  37.     mov    cl,8
  38. add_mcb_2:
  39.     shl    dh,1
  40.     rcr    dl,1
  41.     loop    add_mcb_2
  42.     mov    dh,dl
  43.   endif
  44.  
  45.     mov    al,dh            ; get ms 8 bits,
  46.     rol    al,1
  47.     rol    al,1
  48.     rol    al,1            ; put 3 bits at bottom
  49.     and    al,7
  50.     mov    bl,al            ; save in bl
  51.     xor    bh,bh            ; make bx into an index to the byte.
  52.  
  53.     mov    al,dh            ; get ms 8 bits,
  54.     ror    al,1
  55.     ror    al,1            ; but at bottom
  56.     and    al,7
  57.     mov    cl,al            ; save in cl
  58.     mov    al,1
  59.     shl    al,cl            ; set the correct bit,
  60.  
  61.     or    [bx+di],al
  62.     pop    cx
  63.     ret
  64.  
  65. ;
  66. ;    dx is high,
  67. ;    bx is low.
  68. ;    al is data
  69.  
  70. upd_crc:
  71.     push    cx
  72.     mov    cx,8        ; do 8 bits
  73.     mov    ah,0
  74. upd_crc1:
  75.     shl    bx,1        ; shift bx
  76.     rcl    dx,1        ; through dx
  77.     rcl    ah,1        ; carry is at bottom of ah
  78.     xor    ah,al        ; xor with lsb of data
  79.     rcr    ah,1        ; and put in carry bit
  80.     jnc    upd_crc2
  81. ;
  82. ;    autodin is x^32+x^26+x^23x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1
  83. ;
  84.     xor    dx,0000010011000001b
  85.     xor    bx,0001110110110110b + 1    ;plus one for end-around carry.
  86. upd_crc2:
  87.     shr    al,1        ; shift the data
  88.     loop    upd_crc1
  89.     pop    cx
  90.     ret
  91.  
  92.