CS 2810 Objective: The objective of this lab assignment is to demonstrate your ability in Moving...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
■ CS 2810 Objective: The objective of this lab assignment is to demonstrate your ability in Moving data from memory locations to a register and vice versa; Negating a positive integer; Adding two numbers with both numbers stored in registers or one stored in a register and one being a literal; ■ Programming Assignment 1 Performing logical ADD, NOT, and OR operations; Checking the parity of a number. Lab Statement: Two numbers, X and Y, are stored in memory locations Ox3050 and Ox3051 respectively. Write an LC-3 machine language program that does the following: 1. Compute the sum of X and Y and place it at location Ox3052. 2. Compute X - Y and store the result at location x3053 3. Compute X AND Y and store the result at location Ox3054. 4. Compute NOT(X) and store the result at location Ox3055. 5. Compute X OR Y and store the result at location Ox3056. 6. Compute X + 3 and store the result at location Ox3057. 7. Computer X-3 and store the result at location Ox3058. 8. If X is even, place 0 at location Ox3059; otherwise, meaning if X is odd, place 1 at 0x3059. LC-3 Syntax: 1. Move data to/from memory locations. LC-3 has three set of instructions to move data to/from memory locations: LD/ST, LDR/STR, and LDI/STI. They differ in how they calculate the address of the memory location. LD/ST use a PCoffset9, meaning the address is calculated by adding the incremented PC to a 9-bit offset supplied by the user in the instruction. Since the offset is limited to a 9-bit 2's complement integer, the range of the offset is -256 to 255 in decimal, or x1FF-xOFF. You can use LD/ST if the target location is within this range. In this lab assignment, if the program begins at x3000, the target locations, x3050-x3058, are within the offset range. We can use LD/ST to move the data around. For example, if the first statement, which is stored in x3000, is to move X, stored in x3050, to RO, the instruction will be formed as followed: Opcode: 0010 Operand 1: 000 (DR) Operand 2: The PC will be incremented to x3001 when this instruction is being executed and the location for X is x3050. Therefore the offset is (x3050)- (x3001)=x004F. So the 9-bit offset is x04F or 001001111. Instruction: 0010000001001111=x204F 2. Subtraction LC-3 does not have an instruction for subtraction. However, X - Y = X + (-Y). We need to form - Y through 2's complement by finding NOT (Y) first then add one to the result. 3. OR operation LC-3 does not have an OR instruction. However, de Morgan rule says, AANDB = ĀORB = A OR B. Therefore A or B can be evaluated as NOT((NOT A) AND (NOT B)) 4. Checking parity In binary format, the parity can be decided by the least significant bit, or bit 0. An integer is even if bit 0 is 0 and is odd if bit 0 if 1. One way to determine the parity is to AND the number with x0001 (which is a bit mask for this purpose). Testing: Use the following pairs of (X, Y) for testing: (10, 21), (-11, 15), (9, 12). Submission: 1. Your machine code, either in binary or hex, in a text file. 2. For each pair of (X, Y), the screen shot of contents of locations Ox3050 through Ox3059. Content X Y X + Y X-Y X AND Y Location 0x3050 Ox3051 Ox3052 0x3053 0X3054 0x3055 0x3056 Ox3057 0x3058 0x3059 NOT (X) X OR Y X + 3 X-3 0 if X is even; 1 if X is odd ■ CS 2810 Objective: The objective of this lab assignment is to demonstrate your ability in Moving data from memory locations to a register and vice versa; Negating a positive integer; Adding two numbers with both numbers stored in registers or one stored in a register and one being a literal; ■ Programming Assignment 1 Performing logical ADD, NOT, and OR operations; Checking the parity of a number. Lab Statement: Two numbers, X and Y, are stored in memory locations Ox3050 and Ox3051 respectively. Write an LC-3 machine language program that does the following: 1. Compute the sum of X and Y and place it at location Ox3052. 2. Compute X - Y and store the result at location x3053 3. Compute X AND Y and store the result at location Ox3054. 4. Compute NOT(X) and store the result at location Ox3055. 5. Compute X OR Y and store the result at location Ox3056. 6. Compute X + 3 and store the result at location Ox3057. 7. Computer X-3 and store the result at location Ox3058. 8. If X is even, place 0 at location Ox3059; otherwise, meaning if X is odd, place 1 at 0x3059. LC-3 Syntax: 1. Move data to/from memory locations. LC-3 has three set of instructions to move data to/from memory locations: LD/ST, LDR/STR, and LDI/STI. They differ in how they calculate the address of the memory location. LD/ST use a PCoffset9, meaning the address is calculated by adding the incremented PC to a 9-bit offset supplied by the user in the instruction. Since the offset is limited to a 9-bit 2's complement integer, the range of the offset is -256 to 255 in decimal, or x1FF-xOFF. You can use LD/ST if the target location is within this range. In this lab assignment, if the program begins at x3000, the target locations, x3050-x3058, are within the offset range. We can use LD/ST to move the data around. For example, if the first statement, which is stored in x3000, is to move X, stored in x3050, to RO, the instruction will be formed as followed: Opcode: 0010 Operand 1: 000 (DR) Operand 2: The PC will be incremented to x3001 when this instruction is being executed and the location for X is x3050. Therefore the offset is (x3050)- (x3001)=x004F. So the 9-bit offset is x04F or 001001111. Instruction: 0010000001001111=x204F 2. Subtraction LC-3 does not have an instruction for subtraction. However, X - Y = X + (-Y). We need to form - Y through 2's complement by finding NOT (Y) first then add one to the result. 3. OR operation LC-3 does not have an OR instruction. However, de Morgan rule says, AANDB = ĀORB = A OR B. Therefore A or B can be evaluated as NOT((NOT A) AND (NOT B)) 4. Checking parity In binary format, the parity can be decided by the least significant bit, or bit 0. An integer is even if bit 0 is 0 and is odd if bit 0 if 1. One way to determine the parity is to AND the number with x0001 (which is a bit mask for this purpose). Testing: Use the following pairs of (X, Y) for testing: (10, 21), (-11, 15), (9, 12). Submission: 1. Your machine code, either in binary or hex, in a text file. 2. For each pair of (X, Y), the screen shot of contents of locations Ox3050 through Ox3059. Content X Y X + Y X-Y X AND Y Location 0x3050 Ox3051 Ox3052 0x3053 0X3054 0x3055 0x3056 Ox3057 0x3058 0x3059 NOT (X) X OR Y X + 3 X-3 0 if X is even; 1 if X is odd
Expert Answer:
Answer rating: 100% (QA)
To complete this assignment youll need to write LC3 machine language code to perform the specified operations on the given memory locations Heres a stepbystep guide to help you Load X into a register ... View the full answer
Related Book For
Computer Organization and Design The Hardware Software Interface
ISBN: 978-0124077263
5th edition
Authors: David A. Patterson, John L. Hennessy
Posted Date:
Students also viewed these programming questions
-
This assignment is to demonstrate your ability to use Excel 2013 to track and report stock prices and then use critical thinking to analyze and report the performance of each stock and portfolio You...
-
The CEO of WeStudy has a personal cost of working C(H) = 15H2, where H is the number of days she works hard each quarter. Without any effort, the company's stock is expected be worth $50, but for...
-
Suppose that the following equations describe an economy: C = 170 + 0.60YD M s = 735; P = 1 T = 200 I = 100 - 4i Md = 0.75Y - 6i G = 350 a) what is the equation for equilibrium in the goods market?...
-
Natalie's Bakery pays its 20 hourly employees every Friday. Each of Natalie's employees earns a wage of $10 per hour and works 35 hours per week, spread evenly from Monday through Sunday. During the...
-
An investment offers a total return of 12.3 percent over the coming year. Janice Yellen thinks the total real return on this investment will be only 8 percent. What does Janice believe the inflation...
-
What are the two categories of data mining and knowledge discovery software?
-
A venture capitalist wants to estimate the value of a new venture. The venture is not expected to produce net income or earnings until the end of Year 5 when the net income is estimated at...
-
Karen wishes to have $19,526 cash for a new car 5 years from now. How much should be placed in an account now, if the account pays 5.5% annual interest rate, compounded weekly?
-
Windsor Corporation was organized on January 1, 2020. It is authorized to issue 9,700 shares of 8%, $100 par value preferred stock, and 540,200 shares of no-par common stock with a stated value of $1...
-
This involves implementing a simple university personnel management program. The program contains at least three classes: Staff, Student and Faculty. Your program stores relevant information such as...
-
Which strategy tool technique offers the least benefit to the success of the overall implementation phase when implementing a new health IT technology? Explain with examples.
-
A ray of light, emitted beneath the surface of an unknown liquid with air above it, undergoes total internal reflection as shown in the figure below. (Assume d 21.0 cm and h = 22.7 cm.) m n d What is...
-
(1 point) Reduce the matrix to reduced row-echelon form. 1 3 -8 A = 4 -3 13 -2 -4 10 830 1 3 -8 0 -1 3 0 TO -3
-
Flint Corp. uses a perpetual inventory system. The company had the following inventory transactions in April. Apr. 3 (a) Purchased merchandise from Flounder Ltd. for $27,810, terms 2/10, n/30, FOB...
-
For the circuit shown in fig.(4), Calculate the current in the 62 resistor, using Norton's theorem and find thevenin equivalent , max power transfer. 4 Ohm 10 Ohm Ohm 12 A 8 Ohm 6 Ohm Fig(4)
-
In exchange for land, the company received a 12-month note on January 1. The face amount of the note is $1,000, and the stated rate of interest is 13%, compounded annually. The 13% rate is equal to...
-
To support multiple virtual machines, two levels of memory virtualization are needed. Each virtual machine still controls the mapping of virtual address (VA) to physical address (PA), while the...
-
Rewrite the loop from Exercise 2.29 to reduce the number of MIPS instructions executed. Exercise 2.29 Translate the following loop into C. Assume that the C-level integer i is held in register $t1,...
-
Consider the following instruction: Instruction: AND Rd,Rs,Rt Interpretation: Reg[Rd] = Reg[Rs] AND Reg[Rt] 1. What are the values of control signals generated by the control in Figure 4.2 for the...
-
How can environmental agents that do not cause gene mutations contribute to cancer?
-
With regard to genotypes, what is a true-breeding organism?
-
With regard to biological evolution, which of the following statements is incorrect? Explain why. A. During its lifetime, an animal evolves to become better adapted to its environment. B. The process...
Study smarter with the SolutionInn App