home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / buffers.lbr / CRC.MZC / CRC.MAC
Encoding:
Text File  |  1987-01-14  |  768 b   |  23 lines

  1. ;
  2. ; This crc routine updates the checkword in (bc) using the byte
  3. ; passed in (a). The checkwords computed are suitable for
  4. ; communication with IBM format floppy disks. The two byte checkword
  5. ; is produced by the generating polynomial x**16+x**12+x**5+1.  The
  6. ; checksum should be initialized to 0ffffh (i.e. 0ffffh is passed in
  7. ; bc when the checksum sequence is started). The new checksum is
  8. ; returned in (bc).
  9. ; a,f,b,c
  10. .crc::    push    d
  11.     xra c    ! mov d,a
  12.     rrc     ! rrc ! rrc ! rrc
  13.     ani    0fh;            mask
  14.     xra d    ! mov e,a
  15.     rrc    ! rrc ! rrc ! mov d,a
  16.     ani 1fh    ! xra b ! mov c,a
  17.     mov a,d    ! ani 0e0h
  18.     xra e    ! mov b,a
  19.     mov a,d    ! rrc ! ani 0f0h
  20.     xra c    ! mov c,a
  21.     pop    d
  22.     ret
  23. █