Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Introduction to the LC-3 Processor - Lab 8 | MAT 3670, Lab Reports of Mathematics

Material Type: Lab; Class: Principles of Computer Systems; Subject: Mathematics; University: Eastern Illinois University; Term: Unknown 1989;

Typology: Lab Reports

2009/2010

Uploaded on 02/25/2010

koofers-user-mgy
koofers-user-mgy 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MAT 3670: Lab 8
Introduction to the LC-3 Processor
Pre-Lab Exercises
Refer to Chapter 5 of the textbook to obtain an overview of the LC-3 computer. To arrive prepared
for the lab, complete each of the following activities. Refer to Figures 1 and 2 and the code listings
shown in the appendix of this handout.
1. Each 4-digit hexadecimal value in lab8a.asm represents a machine instruction consisting of
16 bits. Using the LC-3 ISA documentation, determine how each of these 16-bit quantities is
to be subdivided. Summarize the action of each of the instructions. Write your answers on
the program listings found in the appendix of this lab.
2. Do the same for lab8b.asm.
3. Figure 1 gives the skeleton of an LC-3 machine language program. Each line is missing 16
bits, which you are to supply. Using the LC-3 ISA, fill in the missing bits needed for each
instruction. Caution is needed here, as it is easy to make a mistake!
4. Using Figure 2 and the LC-3 ISA documentation, trace the execution of this program. This
program makes use of two data values, found at x300b and x300c. In a few sentences, describe
what this program is trying to accomplish. Predict the results of running this program.
5. Suppose the values in memory locations x300b and x300c are interchanged. With this change,
what would the program do?
Lab Exercises
1. Login to your Linux account and descend to your 3670 directory. Create a lab8 directory to
store the files you will need for this lab. Obtain the files for this lab from the course web site,
placing them in your lab8 directory.
2. Use the LC-3 simulator to emulate the execution of each of the two programs lab8a.asm and
lab8b.asm. A demonstration of the simulator will be given either in class or during lab.
3. Using the LC-3 simulator, create a program named lab8c.asm which matches the plan shown
in Figure 1. Write each 16-bit quantity as a hexadecimal value and use .fill statements,
as shown in the two example programs. Run the program. Does it produce the result you
predicted from your pre-lab exercises?
4. Swap the values of memory locations x300b and x300c and run the program again. Was your
pre-lab prediction correct?
5. Write an LC-3 machine language program which will count the number of bits which are set
in the word stored at the location which immediately follows the last instruction (i.e., xf025)
of your program. At the conclusion of your program, the bit count (a number between 0 and
16) should be stored in R0.
Place your program in the file lab8d.asm. Thoroughly test your program. Include explanatory
comments within your program.
pf3

Partial preview of the text

Download Introduction to the LC-3 Processor - Lab 8 | MAT 3670 and more Lab Reports Mathematics in PDF only on Docsity!

MAT 3670: Lab 8

Introduction to the LC-3 Processor

Pre-Lab Exercises

Refer to Chapter 5 of the textbook to obtain an overview of the LC-3 computer. To arrive prepared for the lab, complete each of the following activities. Refer to Figures 1 and 2 and the code listings shown in the appendix of this handout.

  1. Each 4-digit hexadecimal value in lab8a.asm represents a machine instruction consisting of 16 bits. Using the LC-3 ISA documentation, determine how each of these 16-bit quantities is to be subdivided. Summarize the action of each of the instructions. Write your answers on the program listings found in the appendix of this lab.
  2. Do the same for lab8b.asm.
  3. Figure 1 gives the skeleton of an LC-3 machine language program. Each line is missing 16 bits, which you are to supply. Using the LC-3 ISA, fill in the missing bits needed for each instruction. Caution is needed here, as it is easy to make a mistake!
  4. Using Figure 2 and the LC-3 ISA documentation, trace the execution of this program. This program makes use of two data values, found at x300b and x300c. In a few sentences, describe what this program is trying to accomplish. Predict the results of running this program.
  5. Suppose the values in memory locations x300b and x300c are interchanged. With this change, what would the program do?

Lab Exercises

  1. Login to your Linux account and descend to your 3670 directory. Create a lab8 directory to store the files you will need for this lab. Obtain the files for this lab from the course web site, placing them in your lab8 directory.
  2. Use the LC-3 simulator to emulate the execution of each of the two programs lab8a.asm and lab8b.asm. A demonstration of the simulator will be given either in class or during lab.
  3. Using the LC-3 simulator, create a program named lab8c.asm which matches the plan shown in Figure 1. Write each 16-bit quantity as a hexadecimal value and use .fill statements, as shown in the two example programs. Run the program. Does it produce the result you predicted from your pre-lab exercises?
  4. Swap the values of memory locations x300b and x300c and run the program again. Was your pre-lab prediction correct?
  5. Write an LC-3 machine language program which will count the number of bits which are set in the word stored at the location which immediately follows the last instruction (i.e., xf025) of your program. At the conclusion of your program, the bit count (a number between 0 and
    1. should be stored in R0. Place your program in the file lab8d.asm. Thoroughly test your program. Include explanatory comments within your program.

Mathematics 3670: Lab 8 2

Address 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 operation/data x3000 R1 = PC + 10 x3001 R2 = M[R1 + 0] x3002 R3 = M[R1 + 1] x3003 R4 = NOT(R3) x3004 R4 = R4 + 1 x3005 R5 = R2 + R x3006 BRzp x x3007 M[R1+2] = R x3008 BRnzp x300A x3009 M[R1+2] = R x300A TRAP x x300B x x300C x x300D xFFFF

Figure 1: The basic ingredients of an LC-3 program. Consult the documentation for the LC-3 ISA to fill in each of the missing bits.

PC operation R0 R1 R2 R3 R4 R5 R6 R7 n z p M[x300B] x3000 R1 = PC + 10 x

Figure 2: Predicting the execution of an LC-3 program.