home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / zendisk2.zip / LST13-2.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  1KB  |  49 lines

  1. ;
  2. ; *** Listing 13-2 ***
  3. ;
  4. ; Generates the cumulative exclusive-or of all bytes in a
  5. ; 64-byte block of memory by replicating the exclusive-or
  6. ; code 64 times and then executing all 64 instances in a
  7. ; row without branching.
  8. ;
  9.     jmp    Skip
  10. ;
  11. ; The 64-byte block for which to generate the cumulative
  12. ; exclusive-or.
  13. ;
  14. X=1
  15. ByteArray    label    byte
  16.     rept    64
  17.     db    X
  18. X=X+1
  19.     endm
  20. ;
  21. ; Generates the cumulative exclusive-or of all bytes in a
  22. ; 64-byte memory block.
  23. ;
  24. ; Input:
  25. ;    SI = pointer to start of 64-byte block for which to
  26. ;        calculate cumulative exclusive-or
  27. ;
  28. ; Output:
  29. ;    AH = cumulative exclusive-or of all bytes in the
  30. ;        64-byte block
  31. ;
  32. ; Registers altered: AX, SI
  33. ;
  34. CumulativeXor:
  35.     sub    ah,ah    ;initialize our cumulative XOR to 0
  36.     rept    64
  37.     lodsb        ;get the next byte and
  38.     xor    ah,al    ; XOR it into the cumulative result
  39.     endm
  40.     ret
  41. ;
  42. Skip:
  43.     call    ZTimerOn
  44.     cld
  45.     mov    si,offset ByteArray
  46.                 ;point to the 64-byte block
  47.     call    CumulativeXor    ;get the cumulative XOR
  48.     call    ZTimerOff
  49.