Question

Given the following array named 'array1': array1 DWORD 50h, 51h, 52h, 53h Write instructions to swap...

Given the following array named 'array1':

array1 DWORD 50h, 51h, 52h, 53h

Write instructions to swap the items in array1 (using only MOV and XCHG instruction), so that the array1 become:

53h, 51h, 50h, 52h

( That means the first item in the array is 53h, second item is 51h, third item is 50h, forth item is 52h).

You can use registers to perform the MOV and XCHG operation.  

Write the code to perform above mentioned transformation.

Homework Answers

Answer #1

#include <stdio.h>

int main()
{
//Initialize array   
int arr[] = { 50, 51, 52, 53};   
  
//Calculate length of array arr
int length = sizeof(arr)/sizeof(arr[0]);
  
printf("Original array: \n");
for (int i = 0; i < length; i++) {   
printf("%d ", arr[i]);   
}
  
printf("\n");
  
printf("Array in reverse order: \n");
//Loop through the array in reverse order
for (int i = length-1; i >= 0; i--) {   
printf("%d ", arr[i]);   
}   
return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Assignment-I Write the output for the following instructions MOV B , A             Before instruction execution, the...
Assignment-I Write the output for the following instructions MOV B , A             Before instruction execution, the contents of registers B and A are                                  Rd= B= XBH                         Rs= A = 1FH              After the execution of instruction.                                 Rd= B = ?                         Rs= A = ? ADD B If A= E 3H   B=  0 4H then after the  execution of the above instruction the content of A = ? SUI 03H If the value of A = 15Hthen after the execution of the above instruction...
**please write code with function definition taking in input and use given variable names** for e.g....
**please write code with function definition taking in input and use given variable names** for e.g. List matchNames(List inputNames, List secRecords) Java or Python Please Note:    * The function is expected to return a STRING_ARRAY.      * The function accepts following parameters:      *  1. STRING_ARRAY inputNames      *  2. STRING_ARRAY secRecords      */ Problem Statement Introduction Imagine you are helping the Security Exchange Commission (SEC) respond to anonymous tips. One of the biggest problems the team faces is handling the transcription of the companies reported...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
PRODUCTION PLANNING AT VIKTOR LENAC SHIPYARD Professor Giorgio Sinković and Professor David M. Currie prepared this...
PRODUCTION PLANNING AT VIKTOR LENAC SHIPYARD Professor Giorgio Sinković and Professor David M. Currie prepared this case solely to provide material for class discussion. The authors do not intend to illustrate either effective or ineffective handling of a managerial situation. The authors may have disguised certain names and other identifying information to protect confidentiality. This publication may not be transmitted, photocopied, digitized, or otherwise reproduced in any form or by any means without the permission of the copyright holder. Reproduction...
Wal-Mart Online Wal-Mart is one of the largest companies in America. It is definitely the largest...
Wal-Mart Online Wal-Mart is one of the largest companies in America. It is definitely the largest retailer, both in terms of the number of stores (8,970 worldwide in 2011) and the level of sales ($419 billion from the 2011 Annual Report). By pushing suppliers to continually reduce costs, Wal-Mart is known for pursuing low prices and the stores often attract customers solely in-terested in lower prices. With Wal-Mart’s expansion into groceries, the company has be-come the largest retail grocer in...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From the April 2004 Issue Save Share 8.95 In 1991, Progressive Insurance, an automobile insurer based in Mayfield Village, Ohio, had approximately $1.3 billion in sales. By 2002, that figure had grown to $9.5 billion. What fashionable strategies did Progressive employ to achieve sevenfold growth in just over a decade? Was it positioned in a high-growth industry? Hardly. Auto insurance is a mature, 100-year-old industry...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT