Reverse the elements in a given array

AI Thread Summary
To reverse the elements of array X1, a sequence of assembly statements is required. The initial code setup includes a loop intended to run five times, but it lacks a proper loop statement targeting the loop's label. Once this is corrected, the code should function as intended. Debugging is recommended to verify the program's correctness, specifically by inspecting the array contents after the loop completes. The expected final array should display values in reverse order, such as 1ah, 90h, 80h, ..., 10h.
Fatima Hasan
Messages
315
Reaction score
14

Homework Statement


Write a sequence of statements to REVERSE the elements of array X1.

Homework Equations


-

The Attempt at a Solution


Here's my work :
reverse.png

Could somebody check my answer please ?
 

Attachments

  • reverse.png
    reverse.png
    6.7 KB · Views: 736
Physics news on Phys.org
Is this assembly? Are you able to run the code?
 
scottdave said:
Is this assembly?
yes
 
Fatima Hasan said:
Could somebody check my answer please ?
Your code doesn't work, but you're not far off.
It looks like you are setting up a loop to run 5 times, and you have a label at the start of your loop, but you are missing a loop statement at the bottom of the loop body, and whose target is the label. After you fix that, I believe your code will do what it's supposed to do.
When you get your code to run, you really should use your debugger to see if the program is working correctly. Set a breakpoint on the first line after the loop statement, and inspect the contents of the array. After the loop finishes the array contents should be 1ah, 90h, 80h, ..., 10h.
 
Last edited:
  • Like
Likes berkeman and scottdave

Similar threads

Replies
21
Views
3K
Replies
5
Views
2K
Replies
4
Views
1K
Replies
5
Views
2K
Replies
1
Views
1K
Replies
4
Views
5K
Replies
3
Views
2K
Replies
3
Views
1K
Back
Top