Question: CS 2810 Objective: The objective of this lab assignment is to demonstrate your ability in Moving data from memory locations to a register and

CS 2810 Objective: The objective of this lab assignment is to demonstrate your ability in Moving data from 2. Subtraction LC-3 does not have an instruction for subtraction. However, X - Y = X + (-Y). We need to form

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

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 full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!