LC-3 Operations

LC-3 has three type of operations: ADD, AND, and NOT. I’ll describe them below with an accompanying Truth Table if necessary.

*Note: I’ll be accompanying this with an intro to the LC-3 Programming Environment soon…This was merely posted for those who needed help with their CS course. I’ll post the remaining guides soon…

First of all before we begin, let’s say these registers hold the following values…

R2 = 10
R3 = 15
R4 = 1;

The ADD Operation

The first ADD operation allows you to add the content of two registers and save the result in a register.

ADD	R2, R3, R4

R2 denotes the Destination Register
R3, and R4 denotes the Registers whose contents will be added

Translation:
R2 = R3 + R4
R2 = 15 + 1
R2 would contain 16.

ADD	R2, R3, immediate value


R2 denotes the Destination Register
R3 is the register whose contents will be added to an immediate value (can you determine the value of the highest/lowest value that can be represented here?) You can place values such as 5, 10, 0, -2, -5…so on

Translation with Example:
R2 = R3 + 10;
R2 = 15 + 10;
R2 = 25;

The AND Operation

The truth table for the AND operation between two binary digits is below. Easiest way to remember, is simply to know that in order to get TRUE or 1, all contents that are ANDed must be 1 or TRUE.

A B A AND B
0 0 0
0 1 0
1 0 0
1 1 1
AND	R2, R3, R4

R2 is the Destination Register
R3 and R4 are the Registers whose contents will be ANDed

Translation:
R2 = R3 AND R4;
R2 = 1111 AND 0001
R2 = 0001

AND	R2, R3, immediate value

R2 is the Desination Register
R3 is the register whose contents will be ANDed with an immediate value

Translation:
R2 = R3 AND 5;
R2 = 1111 AND 0101
R2 = 0101

The NOT Operation

The truth table for the NOT Operation is below. To remember, simply invert the bits whenever you see a NOT operation.

A NOT A
0 1
1 0
NOT	R1, R4

R1 is the Destination Register
R2 is the register whose contents will be NOT

Translation:
R1 = NOT R4
R1 = NOT 0001
R1 = 1110

Summary

It is critical for you to understand how these instructions operate fully. I’ll be adding Data Movement, Control, and Trapvector table instructions soon.

Tags: , , , , , ,