home *** CD-ROM | disk | FTP | other *** search
/ Graphics Programming Black Book (Special Edition) / BlackBook.bin / disk1 / zenasmlg / zen_list.exe / LST10-5.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  610b  |  27 lines

  1. ;
  2. ; *** Listing 10-5 ***
  3. ;
  4. ; Searches a word-sized array for the first element
  5. ; greater than 10,000, using SCASW.
  6. ;
  7.     jmp    Skip
  8. ;
  9. WordArray    dw    1000 dup (0), 10001
  10. ;
  11. Skip:
  12.     call    ZTimerOn
  13.     mov    di,seg WordArray
  14.     mov    es,di    ;SCASW always uses ES:SI as a
  15.             ; memory pointer
  16.     mov    di,offset WordArray
  17.     mov    ax,10000 ;value we'll compare with
  18.     cld        ;make SCASW add 2 to DI after
  19.             ; each execution
  20. SearchLoop:
  21.     scasw        ;compare the next element to 10,000
  22.     jae    SearchLoop ;if not greater than 10,000, do
  23.                ; the next element
  24.     dec    di    ;point back to the matching word
  25.     dec    di
  26.     call    ZTimerOff
  27.