12/9/2018 2.
Program for Exchanging Pairs of Array Values in Assembly Language using Visual Studio
Programming Tutorials
SUBSCRIBE
2. Program for Exchanging Pairs of Array
Values in Assembly Language using Visual
Studio
December 13, 2017
Chapter 4
Data Transfers, Addressing, and Arithmetic
Assembly Language Programming Exercise
Problem # 2:
Write a program with a loop and indexed addressing that exchanges
every pair of values in an array with an even number of elements.
Therefore, item i will exchange with item i+1, and item i+2 will
exchange with item i+3, and so on.
Solution:
.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword
.data
array dword 1,2,3,4,5,6,7,8
.code
main proc
mov esi, OFFSET array
mov ecx, LENGTHOF array -1
myLoop:
MOV eax,[esi]
[Link] 1/3
12/9/2018 2. Program for Exchanging Pairs of Array Values in Assembly Language using Visual Studio
XCHG eax,[esi+4]
Programming Tutorials
MOV [esi],eax
SUBSCRIBE
add esi, TYPE array
add esi, TYPE array
loop myLoop
invoke ExitProcess,0
main endp
end main
Let me know in the comment sec on if you have any ques on.
Previous Post:
Conver ng from Big Endian to Li le Endian
Next Post:
Summing the Gaps between Array Values
ASSEMBLY BASICS ASSEMBLY LANGUAGE FOR X86 PROCESSORS CHAPTER 4
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE COMPUTER SCIENCE
DATA TRANSFERS ADDRESSING AND ARITHMETIC EXERCISE SOLUTION VISUAL STUDIO
Reactions: funny (0) interesting (0) cool (0)
[Link] 2/3