Question: First Assembly Program Please see the attached C++ program, first.cpp. Write an assembly program that produces the same results as the code in this program.
First Assembly Program Please see the attached C++ program, first.cpp. Write an assembly program that produces the same results as the code in this program. In other words, you should allocate memory locations by the same name and of the same type shown in this program, and carry out equivalent operations to change those memory locations in the same way. Note that the iostream library and cout statements are commented out. We have not yet seen mechanisms to produce output in assembly programs. However, if you uncomment those parts of the C++ program, you can see values of the variables. Of course, you could run the program using the Visual Studio debugger to observe the variable changes. When writing the assembly program, use the debugger to verify that the named memory locations result in the same values that are produced by the C++ program. Heres a hint for verifying your values. You can use the iostream and iomanip libraries and the hex manipulator to cause the cout statements to output values in hexadecimal form. Include comments in your assembly code to explain how you are implementing the equivalent C++ code. You might include a comment that includes the C++ statement just before your group of instructions that carries out the equivalent assembly code.
long var1 = 15; long var2 = 0x0A; long var3 = -7; long var4; // uninititalized short var5 = -21; short var6 = 0x31; short var7 = 1; short var8; // uninitialized char var9 = 'd'; //#includeint main () { var3 += var1; // var3: 8 var4 = (var3 - var2) + var1; // var4: 13 var1 = --var3 - ++var2; // var1: -4, var2: 11, var3: 7 var5 += 20; // var5: -1 var8 = (var5 - var6) + (var7 - 2); // var8: -51 // Note, adding a 16 bit variable to a 32 bit variable var1 += var6; // var1: 45 var9 -= 0x20; // var9: 'D' // std::cout << "var1: " << var1 << std::endl; // 45 // std::cout << "var2: " << var2 << std::endl; // 11 // std::cout << "var3: " << var3 << std::endl; // 7 // std::cout << "var4: " << var4 << std::endl; // 13 // std::cout << "var5: " << var5 << std::endl; // -1 // std::cout << "var6: " << var6 << std::endl; // 49 // std::cout << "var7: " << var7 << std::endl; // 1 // std::cout << "var8: " << var8 << std::endl; // -51 // std::cout << "var9: " << var9 << std::endl; // 'D' return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
