Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE FOLLOW THE QUESTION ON THE IMAGE TO MODIFY THE CODE BELOW THANKS. // MODULE B: Method 2: Embedding an in-line asssembly language module in
PLEASE FOLLOW THE QUESTION ON THE IMAGE TO MODIFY THE CODE BELOW THANKS. // MODULE B: Method 2: Embedding an in-line asssembly language module in a C progrmming #include "stdafx.h" #include "stdio.h" #include int main () { printf(" Lab_No_01_Getting_Stated_into_x86_Assembly_from_a_C++_program "); // Lab number and title here printf(" Module B: Embedding an in-line asssembly language module in a C progrmming "); printf(" James Rodriguez, ID#12345678 "); // Student's name here printf(" CET3510-E205 "); // Student's Class here printf(" Submission date: January 20, 2019 "); // Date of the Student's program when submitted here printf(" Due date: January 28, 2019 "); // Date of the Student's program due date printf(" Example 1.2 SimpleMathASM.cpp "); // Student's file name for the program here printf(" file name: SimpleMathASM.cpp "); // Student's file name for the program here printf("----------------------------------------- "); printf("Hello "); printf("Using EAX, EBX, and ECX 32-bits Registers "); int x, y, sum, diff; //A. Find the sum of two integers (sum = x + y) printf("Enter two integers from a keynoard to add "); scanf_s("%d%d", &x,&y); _asm { MOV EAX, 0; // To initilized register in zeros MOV EBX, 0; // To initilized register in zeros MOV ECX, 0; // To initilized register in zeros MOV EAX, x; // Load EAX with the value x MOV EBX, y; // Load EBX with the value y MOV ECX, EAX; ADD ECX, EBX; //Add EBX to ECX MOV sum, ECX; // sum = x + y this operation is substituted using 32-bit registers; } printf("Addition result = %d ", sum); getchar(); // Hold the consult for result printf("******************************************************************************* "); //B. Find the difference of two integers (sub = x - y) printf("Enter two integers from a keynoard to minus "); scanf_s("%d%d", &x,&y); _asm { MOV EAX, 0; // To initilized register in zeros MOV EBX, 0; // To initilized register in zeros MOV ECX, 0; // To initilized register in zeros MOV EAX, x; // Load EAX with the value x MOV EBX, y; // Load EBX with the value y MOV ECX, EAX; SUB ECX, EBX; //Substract EBX from ECX MOV diff, ECX; // sub = x - y; this operation is substituted using registers; } printf("Subtraction result = %d ", diff); system ("pause"); // Hold the consult for result return(0); } Write an in-line assembly language module in a C program (a) Display your name and class and today's date (b) Define the data type short int to replace int, use registers AX, BX, CX to replace EAX, EBX, and ECX, respectively. (c) Define the data type char to replace int, use registers AL, BL, CL to replace EAX, EBX, and ECX, respectively (d) Repeat the above steps of example 1 and example 2. (e) Show your console output to your instructor. (t) Write your lab report for submission
PLEASE FOLLOW THE QUESTION ON THE IMAGE TO MODIFY THE CODE BELOW THANKS.
// MODULE B: Method 2: Embedding an in-line asssembly language module in a C progrmming
#include "stdafx.h"
#include "stdio.h"
#include
int main ()
{
printf(" Lab_No_01_Getting_Stated_into_x86_Assembly_from_a_C++_program "); // Lab number and title here
printf(" Module B: Embedding an in-line asssembly language module in a C progrmming ");
printf(" James Rodriguez, ID#12345678 "); // Student's name here
printf(" CET3510-E205 "); // Student's Class here
printf(" Submission date: January 20, 2019 "); // Date of the Student's program when submitted here
printf(" Due date: January 28, 2019 "); // Date of the Student's program due date
printf(" Example 1.2 SimpleMathASM.cpp "); // Student's file name for the program here
printf(" file name: SimpleMathASM.cpp "); // Student's file name for the program here
printf("----------------------------------------- ");
printf("Hello ");
printf("Using EAX, EBX, and ECX 32-bits Registers ");
int x, y, sum, diff;
//A. Find the sum of two integers (sum = x + y)
printf("Enter two integers from a keynoard to add ");
scanf_s("%d%d", &x,&y);
_asm
{
MOV EAX, 0; // To initilized register in zeros
MOV EBX, 0; // To initilized register in zeros
MOV ECX, 0; // To initilized register in zeros
MOV EAX, x; // Load EAX with the value x
MOV EBX, y; // Load EBX with the value y
MOV ECX, EAX;
ADD ECX, EBX; //Add EBX to ECX
MOV sum, ECX;
// sum = x + y this operation is substituted using 32-bit registers;
}
printf("Addition result = %d ", sum);
getchar(); // Hold the consult for result
printf("******************************************************************************* ");
//B. Find the difference of two integers (sub = x - y)
printf("Enter two integers from a keynoard to minus ");
scanf_s("%d%d", &x,&y);
_asm
{
MOV EAX, 0; // To initilized register in zeros
MOV EBX, 0; // To initilized register in zeros
MOV ECX, 0; // To initilized register in zeros
MOV EAX, x; // Load EAX with the value x
MOV EBX, y; // Load EBX with the value y
MOV ECX, EAX;
SUB ECX, EBX; //Substract EBX from ECX
MOV diff, ECX;
// sub = x - y; this operation is substituted using registers;
}
printf("Subtraction result = %d ", diff);
system ("pause"); // Hold the consult for result
return(0);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started