home *** CD-ROM | disk | FTP | other *** search
/ Graphics Programming Black Book (Special Edition) / BlackBook.bin / disk1 / zenasmlg / zen_list.exe / LST7-8.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  1KB  |  49 lines

  1. ;
  2. ; *** Listing 7-8 ***
  3. ;
  4. ; Strips the high bit of every byte in a byte-sized array
  5. ; without using a segment override prefix.
  6. ;
  7.     jmp    Skip
  8. ;
  9. ARRAY_LENGTH    equ    1000
  10. TestArray    db    ARRAY_LENGTH dup (0ffh)
  11. ;
  12. ; Strips the high bit of every byte in a byte-sized array.
  13. ;
  14. ; Input:
  15. ;    CX = length of array
  16. ;    ES:BX = pointer to start of array
  17. ;
  18. ; Output: none
  19. ;
  20. ; Registers altered: AL, BX
  21. ;
  22. StripHighBits    proc    near
  23.     push    ds        ;save normal DS
  24.     mov    ax,es        ;point DS to the array's
  25.     mov    ds,ax        ; segment
  26.     mov    al,not 80h    ;bit pattern for stripping
  27.                 ; high bits, loaded into a
  28.                 ; register outside the loop
  29.                 ; so we can use fast
  30.                 ; register-to-memory ANDing
  31.                 ; inside the loop
  32. StripHighBitsLoop:
  33.     and    [bx],al        ;strip this byte's high bit
  34.     inc    bx        ;point to next byte 
  35.     loop    StripHighBitsLoop
  36.     pop    ds        ;restore normal DS
  37.     ret
  38. StripHighBits    endp
  39. ;
  40. Skip:
  41.     call    ZTimerOn
  42.     mov    bx,seg TestArray
  43.     mov    es,bx
  44.     mov    bx,offset TestArray    ;point to array
  45.                     ; which will have
  46.                     ; high bits stripped
  47.     call    StripHighBits        ;strip the high bits
  48.     call    ZTimerOff
  49.