Microsoft CC Inline Assembler Questions X Y Z are signed 32b

Microsoft C/C++ Inline Assembler Questions;

X, Y, Z are signed 32-bit integers and that the priorities of arithmetic operations must be taken into account.

1) Compute X + Y – Z

2) Compute –2XY – 3Z

3) Compute X – Y / (Z – 1)^3

4) Compute (X + Y – Z) / (–2XY – 3Z)

(Please solve as in the demonstrated template below)

// PracticalTask2.cpp : Defines the entry point for the console application.

Solution

#include \"stdafx.h\" #include int main() { int first = 3; int second = 2; int third = 4; int result; // The following Inline Assembler instructions are equivalent to the statement: // result = first + second; __asm { mov eax, [first] // store value of variable first into CPU register EAX mov ebx, [second] // store value of variable second into CPU register EBX mov ecx, [third] // store value of varibale third into CPU register ECX add eax, ebx, ecx // sum the values of CPU registers EAX, EBX and ECX // and store the result in the register EAX mov [result], eax // save the sum into variable result } __asm { __asm { mov eax, [first] // store value of variable first into CPU register EAX mov ebx, [second] // store value of variable second into CPU register EBX mov ecx, [third] // store value of varibale third into CPU register ECX multiply eax, ebx, ecx // multiply the values of CPU registers EAX, EBX and ECX // and store the result in the register EAX mov [result], eax // save the sum into variable result } __asm { mov eax, [first] // store value of variable first into CPU register EAX mov ebx, [second] // store value of variable second into CPU register EBX mov ecx, [third] // store value of varibale third into CPU register ECX multiply eax, ebx, ecx // multiplication of value with 3 and 3 the values of CPU registers EAX, EBX and ECX // and store the result in the register EAX mov [result], eax // save the sum into variable result } // To check the result value, output variables to the console: printf(\"%d + %d = %d\ \", first, second, result); getchar(); // Wait for the Enter key return 0; }
Microsoft C/C++ Inline Assembler Questions; X, Y, Z are signed 32-bit integers and that the priorities of arithmetic operations must be taken into account. 1) C

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site