I'm trying to swap element 1 with element 5 and element 2 with element 4, in the dword array using xchg instruction. I'm only asking for guidance to help me get started. I have this so far. I'm trying to use these instructions for the dword array.
mov ax,val1
xchg ax,val2
mov val1,ax
.data
myArray BYTE 2,4,6,8,10
DArray DWORD 5 DUP(?)
.code
main PROC
mov esi, OFFSET myArray
mov edi, OFFSET DArray
mov ecx, 5
L1: movzx eax, byte ptr [esi]
mov [edi], eax
inc esi
add edi, 4
call WriteDec
loop L1
mov al, byte ptr [esi]
xchg al, byte ptr [esi]+4
mov byte ptr[esi], al
call WriteDec
mov ah, byte ptr [esi]+1
xchg ah, byte ptr [esi]+3
mov byte ptr [esi]+1, ah
call WriteDec
The swap in the byte array lacks the setting of the
ESI
register.