.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword
.data
array DWORD 1,2,3,4,5,6,7,8
.code
main proc
; must offset the array so that esi regester
; holds the address of the first item in the array
mov esi, OFFSET array
; ecx register is now 4
mov ecx, LENGTHOF array / 2
myLoop: ; will loop 4 times because ecx has 4
; get the pair numbers from array
mov eax, [esi]
mov ebx, [esi + 4]
; swap the pairs in array
mov [esi], ebx
mov [esi + 4], eax
; A DWORD is 4 bytes so we must increment the
; esi register by 8 to get the next pair.
add esi, TYPE array * 2
loop myLoop
invoke ExitProcess,0
main endp
end main