Swap_Values_In_Array (Chapter 4, Supplied) Write an ASM program to swap four DWO
ID: 3883931 • Letter: S
Question
Swap_Values_In_Array (Chapter 4, Supplied) Write an ASM program to swap four DWORD values in an array with mov and xchg instructions Your program should show the tollowing outputs as before and after swapped Dump of offset 004050A0 00001000 00002000 00003000 00004000 Dump of offset 004050AO 00002000 00004000 00001000 00003000 Press any key to oontinue . . For a template project with Irvine32 library, download Project32.zip. Then you can copy the following code Now you must use Irvine32 lib at Link libraries and example programs #14 for an example TITLE Chapter 4, zd supplied (SwapValues.asm)Explanation / Answer
SwapValues.asm
TITLE Chapter 4, zd supplied (SwapValues.asm)
INCLUDE Irvine32.inc
.data
dwArray DWORD 1000h, 2000h, 3000h, 4000h
.code
; Fill the requirement to swap DWORD elements in dwArray
SwapValues PROC
; Show original data
call Display
mov eax, dwArray
xchg [dwArray + 8], eax
xchg [dwArray + 12], eax
xchg [dwarray + 4], eax
mov dwArray, eax
; Show swapped data
call Display
exit
SwapValues ENDP
; A procedure to show dwArray memory by calling DumpMem
Display PROC
mov esi, offset dwArray
mov ebx, type dwArray
mov ecx, lengthof dwArray
call DumpMem
ret
Display ENDP
END ;SwapValues
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.