Docsity

LC-3 Assembly Problem Set: MP3 Warm-up, Debugging, and Problem Solving, Exams of Biomedical Engineering

Toggle sidebar
bg1
Problem 1 (10 points): MP3 Warm-up
The computation involved in creating the next generation for the "Life" game is fairly expensive.
One potential method of avoiding extra computations is to not compute anything if and only if
there are less than two live cells in the board (because under those conditions it is guaranteed that
all cells will be dead in the next generation).
Try writing the code for a subroutine that scans a 4x4 board (i.e. table of 16 elements) to
determine the number of live cells. The table starts at x4000. Also as you may recall a dead cell
is represented by x0000 and a live cell by x0001.
Specifics
1. Open a terminal, and type 'ece190' (yes, run the 'ece190' script).
2. Execute 'cd mp3'
3. Execute 'ls -l' and you will see 'mp3.asm'. If you do not please contact your TA
immediately.
4. MAIN is complete and given.
5. COUNT_LIVE_CELLS needs to meet the following specification:
o Inputs: NONE
o Outputs: R0 - x0000 if there are two or fewer live cells, x0001 if there are three or
more live cells.
o Registers must be callee-saved.
o Table values will ALWAYS be either x0000 or x0001
6. No test vector files or make commands have been provided.
7. A 'board.asm' file has been provided that is completely dead. Feel free to modify that for
testing purposes.
8. To compile the code type 'lc3as board.asm' and 'lc3as mp3.asm'
9. To debug/test the code type 'lc3sim-tk board.obj' then from within the GUI load the
'mp3.obj' file.
10. If you modify board.asm you will need to recompile it.
pf3

Partial preview of the text

Download LC-3 Assembly Problem Set: MP3 Warm-up, Debugging, and Problem Solving and more Exams Biomedical Engineering in PDF only on Docsity!

Problem 1 (10 points): MP3 Warm-up

The computation involved in creating the next generation for the "Life" game is fairly expensive. One potential method of avoiding extra computations is to not compute anything if and only if there are less than two live cells in the board (because under those conditions it is guaranteed that all cells will be dead in the next generation).

Try writing the code for a subroutine that scans a 4x4 board (i.e. table of 16 elements) to determine the number of live cells. The table starts at x4000. Also as you may recall a dead cell is represented by x0000 and a live cell by x0001.

Specifics

  1. Open a terminal, and type 'ece190' (yes, run the 'ece190' script).
  2. Execute 'cd mp3'
  3. Execute 'ls -l' and you will see 'mp3.asm'. If you do not please contact your TA immediately.
  4. MAIN is complete and given.
  5. COUNT_LIVE_CELLS needs to meet the following specification: o Inputs: NONE o Outputs: R0 - x0000 if there are two or fewer live cells, x0001 if there are three or more live cells. o Registers must be callee-saved. o Table values will ALWAYS be either x0000 or x
  6. No test vector files or make commands have been provided.
  7. A 'board.asm' file has been provided that is completely dead. Feel free to modify that for testing purposes.
  8. To compile the code type 'lc3as board.asm' and 'lc3as mp3.asm'
  9. To debug/test the code type 'lc3sim-tk board.obj' then from within the GUI load the 'mp3.obj' file.
  10. If you modify board.asm you will need to recompile it.

Problem 2 (10 points): Debugging

For this part, you will be given a LC-3 assembly language program with a few bugs.

Your task is to find the bugs by inspection and/or by debugging with the LC-3 simulator and fix them. The program only contains a few bugs (3-4) which you must fix by inserting, deleting, or modifying only a few lines of code (3-6).

You may not change the input/output location/format or behavior of the program specified in the program description (in other words, you may only change what is not specified).

Modification of non-buggy code and excessive modification of buggy code will be penalized. We suggest copying the code to a temporary location for experimental modification.

Problem Description:

This program produces a pseudorandom permutation of the numbers from 0 to x1FF, and stores the numbers in consecutive memory locations starting at xDE20. This implies that each memory location is unique and between 0 and x1FF. The correct output is defined by the xor_map function and starts with the following:

xDE20: x xDE21: x xDE22: x008A xDE23: x01CF

Specifics:

  1. Open a terminal, and type 'ece190' (yes, you need to run the 'ece190' script).
  2. Execute 'cd debug`
  3. Execute 'ls -l' and you will see ‘debug.asm'. If you do not please contact your TA immediately.
  4. Code is complete and given, but buggy.
  5. Fix bugs and save the solution in ‘debug.asm’.
  6. No test vector files or make commands have been provided.