Question: TaskS Desciption Please use Introduction to Microsoft C/C++ Inline Assembler to read basic information about Microsoft Visual Studio IDE and features related to the Visual
TaskS Desciption
Please use Introduction to Microsoft C/C++ Inline Assembler to read basic information about Microsoft Visual Studio IDE and features related to the Visual C/C++ Inline Assembler.
You will have to use Visual C/C++ and use its inline or full assembler to implement various arithmetic calculations with signed integers. When implementing the tasks below, try to apply the following instructions:
arithmetic ADD, SUB, IMUL, IDIV, INC, DEC, NEG;
data type extension CBW, CWDE, CDQ;
stack operations PUSH, POP.
Individual TASKS
There are given three arithmetic expression categories A and B:
| Variant | A | B |
| 0 |
|
|
| 1 |
| 5XY 2Z |
| 2 | X + Y + Z |
|
| 3 |
|
|
Assume that the input values for X, Y and Z are at least signed 8-bit integers and that the precedence of mathematic operations must be taken into account.
Select only one expression from each column depending on an individual variant (0, 1, 2 or 3), that must be obtained from your RTU student IDs digits:
Your RTU student IDs 2nd, 8th and 9th digits are: [GA1] (e.g. 123ADB456 2, 5, 6)
Expression A variant: (2nd + 8th) mod 4 = (e.g. 2 + 5 mod 4 = 7 mod 4 3)
Expression B variant: (2nd + 9th) mod 4 = (e.g. 2 + 6 mod 4 = 8 mod 4 0)
Start your solution by creating C/C++ Win32 Console Application in the Microsoft Visual Studio and entering the following project characteristics:
Name: Practice1
Solution Name: COAL
Continue by implementing the lowest level task as shown in the table below and complete the tasks in the given order. You can stop at any level task and assume that if implemented correctly the practice grade will match it. It will be decreased, however, if the solutions contain flaws or errors.
| Grade level | Task to complete |
| 4 | Complete with the working template solution below. |
| 5 | Compute A |
| 6 | Compute B |
| 7 | Compute B A |
| 8 | Compute B * A |
| 9 | Compute B / A |
| 10 | Use at least C/C++ function assert() to demonstrate the testing of solutions. |
Note: Expression calculations, conditions and jumps must be implemented by using Full or Inline Assembler!
Each next level task assumes that you retain all lower level solutions. However, you must not reuse lower grade solutions as function calls from higher level solutions. Instead copy reusable part(s) into higher lever task solution.
SolutionS
Replace this template with your solutions (in-line comments are welcome):
#include "stdafx.h"
#include
#include
// :::
// NOTE:
// char data type is signed 8-bit integer (DB in assembler)
// short data type is signed 16-bit integer (DW in assembler)
// int data type is signed 32-bit integer (DD in assembler)
// You can use any integer data type for input values.
// Update the given template code appropriately.
short solution_for_grade_5(short x, short y, short z)
{
short result;
__asm
{
// Your Inline Assembler instructions for grade 5 go here
// :::
mov [result], ax ; save the result assuming it is in the processor register AX
}
return result;
}
short solution_for_grade_6(short x, short y, short z)
{
short result;
__asm
{
// Your Inline Assembler instructions for grade 6 go here
// :::
mov [result], ax ; saves the result
}
return result;
}
// :::
int main()
{
short first = 320; // Note the short data type range is -32768..32767
short second = -250;
short third = 122;
short result = solution_for_grade_5(first, second, third);
printf("solution_for_grade_5(%d, %d, %d) = %d ", first, second, third, result);
// You might need to invoke solution_for_grade_X() functions several times
// with different parameter values (e.g., to demonstrate branching).
// :::
getchar(); // Wait for the Enter key
return 0;
}
Conclusions
[GA1]Replace with your actual values.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
