home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Programming Black Book (Special Edition)
/
BlackBook.bin
/
disk1
/
zenasmlg
/
zen_list.exe
/
LST8-12.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-02-15
|
1KB
|
39 lines
;
; *** Listing 8-12 ***
;
; Adds together bytes from two arrays, subtracts a byte from
; another array from the sum, and stores the result in a fourth
; array, for all elements in the arrays.
; Uses the AX-specific form of XCHG.
;
jmp Skip
;
ARRAY_LENGTH equ 1000
Array1 db ARRAY_LENGTH dup (3)
Array2 db ARRAY_LENGTH dup (2)
Array3 db ARRAY_LENGTH dup (1)
Array4 db ARRAY_LENGTH dup (?)
;
Skip:
mov ax,offset Array1 ;set up array pointers
mov bx,offset Array2
mov si,offset Array3
mov di,offset Array4
mov cx,ARRAY_LENGTH
call ZTimerOn
ProcessingLoop:
xchg ax,bx ;point BX to Array1,
; point AX to Array2
mov dl,[bx] ;get next byte from Array1
xchg ax,bx ;point BX to Array2,
; point AX to Array1
add dl,[bx] ;add Array2 element to Array1
sub dl,[si] ;subtract Array3 element
mov [di],dl ;store result in Array4
inc ax ;point to next element of each array
inc bx
inc si
inc di
loop ProcessingLoop ;do the next element
call ZTimerOff