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

  1. ;
  2. ; *** Listing 10-19 ***
  3. ;
  4. ; Generates the 8-bit checksum of a 1000-byte array
  5. ; by loading both segment and offset from a far
  6. ; pointer each time through the loop and without
  7. ; using string instructions, as the code generated
  8. ; by a typical high-level language compiler would.
  9. ;
  10.     jmp    Skip
  11. ;
  12. FarSeg    segment    para
  13. ARRAY_LENGTH    equ    1000
  14. ByteArray    db    ARRAY_LENGTH dup (0)
  15.                 ;this array resides in a
  16.                 ; far segment
  17. FarSeg    ends
  18. ;
  19. FarPtr    dd    ByteArray    ;a far pointer to the array
  20. ;
  21. Skip:
  22.     call    ZTimerOn
  23.     mov    cx,ARRAY_LENGTH    ;# of bytes to checksum
  24.     sub    ah,ah        ;zero the checksum counter
  25. ChecksumLoop:
  26.     les    bx,[FarPtr]    ;load both segment and
  27.                 ; offset from the far
  28.                 ; pointer
  29.     inc    word ptr [FarPtr]
  30.                 ;advance the offset portion
  31.                 ; of the far pointer
  32.     add    ah,es:[bx]    ;add the next byte to the
  33.                 ; checksum
  34.     loop    ChecksumLoop
  35.     call    ZTimerOff
  36.