University of Minnesota
Machine Architecture and Organization (sec 010)
index.php

CSci 2021 Lab 0x6

Part 1: Data manipulation puzzles

This section is mostly identical to last two weeks' puzzle lab, in case you need to spend more time on it. There is an extra floating point puzzle for you to work on.

  1. (Lab Setup)

    You can get the handout using the command:

     cp /web/classes/Spring-2020/csci2021/labs/0x6/datalab-handout.tar . 

    or downloaded from here . Once you have your handout downloaded to one of the cselabs machine, eg: vole.cselabs.umn.edu, unzip the handout using the comand tar -xvf datalab-handout.tar . Use the command, make to compile the code. Verify that an executable btest is created.

  2. ( Solving the Puzzles )

    There are six puzzles that need to be solved, namely, negate, bitAnd, tmax, tmin, replaceByte and floatAbsVal. In these puzzles, you need to implement the said operations using as few operators as possible. These functions can be updated in the file bits.c . Once you have updated bits.c with your implementation, compile the code using make and run the executable btest. Your score will be output on the terminal, based on correctness. The legality of your solution can be tested using the program dlc. The detailed instructions regarding the implementation of these functions, and testing, can be found in README.

Part 2: Assembly language debugging

In last week's lab exercise, you had to write several simple functions in assembly, and test whether they worked correctly. However, this week, we shall take the opposite approach. You are given buggy assembly solutions to all of the problems from last time, and need to fix the code. We've given you two files, funcs-buggy.S and funcs-buggy-test.c. As usual you can copy them to your own directory with the command:

	cp /web/classes/Spring-2020/csci2021/labs/0x6/{funcs-buggy.S,funcs-buggy-test.c,Makefile} .
      

funcs-buggy.S is the file which contains the buggy assembly code. The .S file extension is related to the .s extension that is used for assembly language code generated by a compiler; the only difference is that the capital S is for assembly code written by people, and is processed with the same pre-processor as C so we can use macros and C-style comments. Comments already in the file give you some ground-rules about what registers to use, as well as describing what each of the functions do.

The file funcs-buggy-test.c contains code for testing each of the functions in funcs-buggy.S. You can also read the test cases here if you want more examples of what the output of the functions should be.

The file Makefile is used to compile one of the buggy functions. There are six possible functions that can be compiled, namely, three, divide, eight, sign, sign_cmov and triangle. Each of these functions has a single argument and returns a value calculated from this argument. In order to compile a particular function, use the command

	 make function_name 
      
This will create a binary with the same name as the function (if it compiles), which you should then run. For example make three will create a binary named three. Use the command ./three to see whether it can pass these test cases.