home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / zenlib / lst8_12.asm < prev    next >
Assembly Source File  |  1990-02-15  |  1KB  |  39 lines

  1. ;
  2. ; *** Listing 8-12 ***
  3. ;
  4. ; Adds together bytes from two arrays, subtracts a byte from
  5. ; another array from the sum, and stores the result in a fourth
  6. ; array, for all elements in the arrays.
  7. ; Uses the AX-specific form of XCHG.
  8. ;
  9.     jmp    Skip
  10. ;
  11. ARRAY_LENGTH    equ    1000
  12. Array1    db    ARRAY_LENGTH dup (3)
  13. Array2    db    ARRAY_LENGTH dup (2)
  14. Array3    db    ARRAY_LENGTH dup (1)
  15. Array4    db    ARRAY_LENGTH dup (?)
  16. ;
  17. Skip:
  18.     mov    ax,offset Array1    ;set up array pointers
  19.     mov    bx,offset Array2
  20.     mov    si,offset Array3
  21.     mov    di,offset Array4
  22.     mov    cx,ARRAY_LENGTH
  23.     call    ZTimerOn
  24. ProcessingLoop:
  25.     xchg    ax,bx        ;point BX to Array1,
  26.                 ; point AX to Array2
  27.     mov    dl,[bx]        ;get next byte from Array1
  28.     xchg    ax,bx        ;point BX to Array2,
  29.                 ; point AX to Array1
  30.     add    dl,[bx]        ;add Array2 element to Array1
  31.     sub    dl,[si]        ;subtract Array3 element
  32.     mov    [di],dl        ;store result in Array4
  33.     inc    ax        ;point to next element of each array
  34.     inc    bx
  35.     inc    si
  36.     inc    di
  37.     loop    ProcessingLoop    ;do the next element
  38.     call    ZTimerOff
  39.