DOC PREVIEW
UIUC ECE 190 - Machine Problem 2

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

ECE 190 Spring 2011Problem StatementSuggested Algorithm/DecompositionSpecificsStyle and CommentsToolsAutomated TestingHand InGradingLate Work Policy1 ECE 190 Spring 2011 Machine Problem 2 Due: 5 p.m., Wednesday March 2nd, 2011 Problem Statement For this machine problem, you will be writing a program in the LC-3 machine language that reads a 16-bit pattern from memory, analyzes it, and produces two 16-bit outputs, each having the same number of ones and zeros as the original input, but arranged in a particular order: the first with all of the ones in its most significant bits, and the second with all of the ones in its least significant bits. Memory location x4000 will contain the address from which the input should be loaded (i.e., not the input value itself, but the address where you will find it) and your program should store the first output (with the ones stored in the most-significant bits) at x4001 and the second output (with the ones stored in the least-significant bits) at x4002. Example 1: If the relevant parts of the LC3 memory before your program starts look like this: Memory address Interpretation Value x4000 Address of Input x5000 x5000 Input 0001 1011 1100 0100 = x1BC4 Then the memory at x4001 and x4002 after your program finishes should look like this: Memory address Interpretation Value x4001 Most-Significant Output 1111 1110 0000 0000 = xFE00 x4002 Least-Significant Output 0000 0000 0111 1111 = x007F Example 2: If the relevant parts of the LC3 memory before your program starts look like this: Memory address Interpretation Value x4000 Address of Input x3100 x3100 Input 0100 0011 1000 0001 = x4381 The, the memory at x4001 and x4002 after your program finishes should look like this: Memory address Interpretation Value x4001 Most-Significant Output 1111 1000 0000 0000 = xF800 x4002 Least-Significant Output 0000 0000 0001 1111 = x001F2 Suggested Algorithm/Decomposition If you’re not sure how to get started with this MP, we’ve provided a simple systematic decomposition that you can build on to develop your algorithm and your program. You are not required to use this decomposition; we provide it only as a reference to get you started. Note that we use generic action terms here like “check the MSB” and “shift left” – these are an important part of the algorithm, but it is up to you to figure out how to accomplish these actions. Basic algorithm 1. Initialize registers a. load the input b. set one register, say, R0, to all zeros (x0000) c. set another register, say, R1, to all ones (xFFFF or -1) 2. Set up your loop 3. Check the input MSB a. If the MSB is 1, shift the value stored in R0 to the left and add one (shifting in a one) b. If the MSB is 0, shift the value stored in R1 to the left (shifting in a zero) 4. Shift the input value to load the next bit into the MSB position 5. Repeat steps 3-4 until you've examined all 16 bits 6. Store the results Specifics - Your program file must be named mp2.bin. - Your code must be written in the LC-3 machine language. - Your code must begin at memory location x3000. - Your program must use a loop (i.e. there must be at least one conditional branch). - Your code must be well commented and you must provide an introductory paragraph and a register table at the top of your file (see Style Requirements). Style and Comments MP2 must be written in LC-3 machine language (i.e. each instruction is a 16-bit binary word) for any credit to be received. Your code must contain less than 50 16-bit binary words (instructions/data) and you must use a loop in your solution to receive credit. You may find it useful to store some data after the halt, but note that this data also counts toward your 50 binary word limit. In general, you should use the commenting style provided in the Student Manual (see page 35 (PDF page 39 of 72) as an example). For readability reasons, you must not have more than 120 characters on a single line for this MP. If you are writing a long comment that would otherwise exceed 120 characters, you should continue your comment on the next line. At the top of your code, you must include an introductory comment section with your name, date (“Spring 2011” is sufficient), and a very brief explanation of the purpose and general function of your program. Below that paragraph, include a register table explaining the role of each register used by your program.3 For each binary word, you must use spaces to separate instruction fields (e.g. 0010 001 000000100 instead of 0010001000000100). Your code must be well-commented (every line for this MP as it is in binary). Comments must begin with a semicolon and should explain why something is done. While writing “R3 ← R3 - 1” as a comment may be helpful for you as the developer, a comment such as “decrementing loop counter” would be much more useful for anyone attempting to examine your program. Tools You should use a recommended text editor to code your program. To make the machine code conversion and testing process easier and more familiar to you, we have provided you with a simple Makefile. To convert your machine code to an object file, you may simply execute “make” at the terminal (as usual, you must be in the same directory as your code and the provided Makefile). Make will print the results back to the terminal and, if successful (0 errors found), it will produce the mp2.obj object file. Any time you change your code, you should run “make” again to ensure that your object file is up to date. If you prefer not to use make or if you need to do some manual testing/debugging, you may use the “lc3convert mp2.bin” command to manually convert your machine code to an object file. Once successfully converted, you may manually test your code in the LC-3 simulator by typing “lc3sim mp2.obj” at the terminal. Your code must work in the command line LC-3 simulator (i.e. not the graphical simulator) on the Linux EWS machines in order to receive credit. Refer to the Student Manual and Programming Studio notes for more information on using the lc3convert command and LC-3 simulator. Automated Testing To run automated tests on your code, simply run “make test”. Make will use test_mp2 to go through the test cases specified in test_vectors.txt (provided).


View Full Document
Download Machine Problem 2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Machine Problem 2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Machine Problem 2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?