home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / zenlib / lst10_15.asm < prev    next >
Assembly Source File  |  1990-02-15  |  855b  |  33 lines

  1. ;
  2. ; *** Listing 10-15 ***
  3. ;
  4. ; Generates the 8-bit checksum of a 1000-byte array
  5. ; using LODS without a segment override, by setting
  6. ; DS up to point to the far segment for the duration
  7. ; of the loop.
  8. ;
  9.     jmp    Skip
  10. ;
  11. FarSeg    segment    para
  12. ARRAY_LENGTH    equ    1000
  13. ByteArray    db    ARRAY_LENGTH dup (0)
  14. FarSeg    ends
  15. Skip:
  16.     call    ZTimerOn
  17.     push    ds    ;preserve the normal DS setting
  18.     mov    si,seg ByteArray
  19.     mov    ds,si    ;point DS to the far segment for
  20.             ; the duration of the loop-we
  21.             ; won't need the normal DS setting
  22.             ; until the loop is done
  23.     mov    si,offset ByteArray
  24.     mov    cx,ARRAY_LENGTH
  25.     sub    ah,ah    ;zero the checksum counter
  26.     cld        ;make LODSB move the pointer up
  27. ChecksumLoop:
  28.     lodsb        ;get the next byte to checksum
  29.     add    ah,al    ;add the byte into the checksum
  30.     loop    ChecksumLoop
  31.     pop    ds    ;retrieve the normal DS setting
  32.     call    ZTimerOff
  33.