IMMEDIATE ASSEMBLY CODE HELP All instructions included thank
IMMEDIATE ASSEMBLY CODE HELP!
All instructions included, thank you for your help!
Point Value
This assignment is worth 10 points, 3 points per part, plus 1 point for style which includes, but is not limited to Comments, indentation, whitespace, and header comments.
Program Objectives
The objectives of this assignment are as follows. ABET-c, an ability to design, implement, and evaluate a computer-based system, process, component, or program to meet desired need.
Problem
Using the template provided (see attached), write an assembly program that accomplished the following:
Part 1:
1) Write a single statement that computes the product , i is an integer.
Specifications:
a) Place the results in a register of the appropriate size, remember to consider efficient use of available resources.
b) To compute the product, you must use one or more constant expressions that computes the value. No loops or use of anything beyond Chapter 3 in the book should be used.
c) The register must be zeroed out before the result is stored.
Part 2:
1) Write a short block of computational statements that causes the BX register to overflow.
2) Write a short block of computational statements that causes the CX register to set the carry flag.
Specifications:
a) Use variables as opposed to immediate values.
b) Make sure no other computations affect the outcome of this register.
c) The register must be zeroed out before it is used.
Part 3:
Using directives for creating symbolics, write a single statement that computes the number of seconds in a day.
Specifications:
a) Place the result in the EDX register.
b) The statement that is placed in the program and expanded should be SECONDS_IN_DAY.
c) The EDX register should be zeroed out before it is used.
d) Make sure the statement uses the symbolics to the fullest extent; that is, SECONDS_IN_DAY should be the only expression on the instruction line.
Additional information:
A program template is provided below.
DO NOT COPY PASTE THE TEMPLATE! You must type it.
TITLE pa2.asm
; Header comment block as shown in lecture notes
INCLUDE Irvine32.inc
.data
{ your variables should be defined here}
.data?
{used as necessary}
.code
main PROC
{executable code here}
call DumpRegs
exit
main ENDP ; end of main procedure
END main ; end of source code
__________________________________________________________________________________________________________________________________________________
PART 2:
Create an assembly program which adds pairs of numbers pre-stored in an array of appropriate size. Essentially you are adding A + B, B + C, C + D, and D + E.
A = 123h B = 101011011b C = -567d D = -689d E = 238h
1. Declare an array of appropriate size for the data given above.
2. Properly comment your code to include the required header comment.
3. Use DumpRegs to display the results of all operations.
Solution
Here is the C++ code for above problem.
We are using Visual C++ to run this program.
//Header files
#include <iostream>
using namespace std;
//Class definition
class NumberClass
{
long long number;//To store long number
public:
//Constructor
NumberClass(long long n)
{
number=n;
}
//Setter function
void setNumber(long long n)
{
number=n;
}
//Getter function
long long int getNumber()
{
return number;
}
//Operator overloading
NumberClass friend operator +(NumberClass &A, NumberClass &B)
{
return NumberClass(A.number+B.number);
}
};//End of the class
//Main function
int _tmain(int argc, _TCHAR* argv[])
{
cout<<\"Hello, Welcome\"<<endl;
/*Creating object for NumberClass with command argument*/
NumberClass A((long long int)argv[1]);
/*Creating object for NumberClass with command argument*/
NumberClass B((long long int)argv[2]);
/*Creating object for NumberClass by adding two objects of NumberClass*/
NumberClass C=A+B;
//Displaying output
cout<<\"Number A is : \"<<A.getNumber()<<endl;
cout<<\"Number B is : \"<<B.getNumber()<<endl;
cout<<\"Number C is : \"<<endl;
//Expression A+B=C
cout<<A.getNumber()<<\" + \" <<B.getNumber()<<\" = \"<< C.getNumber()<<endl;
system(\"pause\");
return 0;
}



