Reverse the elements in a given array

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
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: 784
Physics news on Phys.org
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   Reactions: berkeman and scottdave