CMPUT 229 - Computer Organization and Architecture I

Lab 2: Tables

229 Lab 2: Hexadecimal Representation and Tables

Hexadecimal and Tables

Information

Hexadecimal

The hexadecimal numbering system (base 16) is used commonly in computing science, due to its easy translation to and from binary. Compared to binary, hexadecimal is extremely succinct, representing 4 binary digits with a single hexadecimal digit. Hexadecimal, unlike decimal, can be translated to binary digit by digit, with digits not affecting each other in the binary result.

Due to this direct correlation, the algorithm to create a binary number from ASCII hexadecimal digits to a binary integer only involves converting the ASCII digit to the value it represents, and shifting left 4 before oring in the next hexadecimal digit.

Going from a binary number to ASCII hexadecimal is similarly simple, involving masking out each 4-bit section and converting it to its associated ASCII character. A full table of ASCII characters can be found here.

Tables

A table in assembly is simply a known amount of allocated space with a known base address. Depending on how many fields need to be in the table, fields in the same row can be stored in the same table or each field may be stored in a separate table while all the fields corresponding to the same entry share an index value. As a rule, in large tables with fields of differing alignments, for instance a word field and a byte field, it is more efficient to use two index-correlated tables than to allocate extra space or deal with unaligned word issues. If the alignments of all the entries match, it is more efficient to use a spatially-correlated table.

Assignment

Your job is to implement the following four functions:

To assist you in the creation and testing of these functions, a RISC-V testing file common.s has been created for you. This testing file creates a simple interactive terminal which allows you to enter a hexadecimal number, uses readHex to convert it to an unsigned integer, countAccess to count the times that integer has been entered, and printHex to print the integer back in hexadecimal. This will allow you to ensure correctness across all your functions. When marking, values will be provided directly to each function, so ensure that your functions do not rely on previous execution of each other. During marking, no guarantees about input are provided beyond those indicated in the specifications for each function.

Notes

CheckMyLab for Lab Tables

Running your solution

To run your solution in CheckMyLab for this lab, you have to make sure that the solution you upload to CheckMyLab includes the code from common.s in the same file and should be located before your solution (it also should not have a ".include" statement).

Making a test case

The format for test cases is as follow:

Example:

c00000001       # run countIntegerAccess with argument 0x00000001
c00000001       # run countIntegerAccess with argument 0x00000001
r00000001       # run readHex with argument "00000001"
r000000aa       # run readHex with argument "000000aa"
w00000001       # get the value of 0x00000001 using readHex then run printHex with that value
waaAAbbBB       # get the value of 0xaaAAbbBB using readHex then run printHex with that value
q               # quit
Note: Do not include comments in your actual test.

Resources

Marking Guide

Assignments too short to be adequately judged for code quality will be given a zero.

Submission

There is a single file to be submitted for this lab. The file name should be tables.s and it should contain only the code for the functions specified above. Make sure to not include a main function in your solution.