Question: Question 1 : Write the assembly code to REVERSE the elements of your name array. Do not copy the elements to any other array. You

Question 1:
Write the assembly code to REVERSE the elements of your name array. Do not copy the elements to any other array. You can use direct or indirect addressing.
If name array is holding Sam then the output for your program should look approximately like following:
maS
Logic:
Address
Contents
----------------------------
00401000
'H'
00401001
'e'
00401002
'l'
00401003
'l'
00401004
'o'
00401005
0(null terminator)
Step 1: (Registers and Pointers)
Set ESI and EDI to the start of the string (First character)
ECX should hold the number of iterations needed for reversal.
Now Update EDI to the end of the string (Last character)
Step2: Logic to swap
Characters are exchanged between ESI and EDI while moving toward the center of the string.
ESI moves forward, EDI moves backward, and characters are swapped:
Iteration 1: 'H'<->'o'(ESI pointing to H , EDI pointing to o
Iteration 2: 'e'<->'l' and so on.
This process continues until the loop completes (ecx iterations).
Step3: Write the array after reversing.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!