Assignment 2, due Jun 15

Part of the homework for 22C:60, Summer 2005
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated, and unless there is what insurance companies call "an act of God" - something outside your control; the only exceptions to this rule will be by advance arrangement.

Remember, summer session goes very quickly! You will fall behind very quickly if you do not keep up with the work.

 

  1. Background: The SMAL assembly language allows you to express the one-byte binary value 11111111 in many ways. You could use any number base from 2 to 36.

    a) Give 5 lines of SMAL code, where each line assembles this value into memory using a different base. Use the following bases: 2, 5, 8, 12 and 16. (Admittedly, base 5 was never very popular, but base 12, duodecimal, once had many advocates, and bases 8 and 16 remain in common use with binary computers.) (1/2 point)

    b) Enter the 5 lines you proposed into an assembly source file, assemble it, and print out the assembly listing file. This will allow you to check the correctness of your answer to part a, and it will allow you to demonstrate that you have found and can run the assembler. (1/2 point)

  2. Question: The following fragment of SMAL assembly code stores a character string into memory in an extremely stupid way. The only reason to code it this way is to make a homework problem.
    .       =       #1000
            W       #6C6C6548
    L1      =       .
    .       =       .+2
            H       2#110111101010111
    L2      =       .
    .       =       L1
            B       'o'
            B       8#40
    .       =       L2
            ASCII   "rld",8#63
    

    a) Give equivalent SMAL code that stores the same character string in memory in the most straightforward possible way. (1 point)

    Hint: There are two problems here! First, figuring out the ASCII codes this loads in memory, and second, figure out what memory addresses get loaded. There is a short clean and readable solution that takes only two lines of assembly code. The SMAL manual, sections 2.2 and 3 will be helpful.

    b) Enter the original assembly code above into an assembly source file, assemble it, and then run the Hawk emulator on the result. Use the emulator to examine the contents of memory location 100016 as ASCII text and take a screen shot (cut and paste from the emulator window) to show that you have done this. You can use this to check your answer to part a! (1/2 point)

    Hint: Appendix A of the Hawk manual gives the emulator commands you will need to examine particular memory locations and change the memory display mode.

  3. Which of the following memory addresses, given in decimal, is aligned on a word boundary, which is aligned on a halfword boundary, and which is not aligned at all? 75, 76, 77, 78 and 79. (1/2 point)

 
 

Setup Instructions for the SMAL and Hawk tools

In order to use the SMAL assembler and the Hawk emulator on the computers in the lab, you will have to install the following text in a special file named .cshrc under your account on the departmental machines.

Log into the lab machines (remotely using an ssh client or locally) and use the text editor of your choice (probably emacs, vi or pico) to open the file .cshrc for editing. You will see something like this:

# KEEP THESE TWO LINES FIRST !!
source /etc/CSHRC

# Add personal Customizations here.

(What does it do? When you start your shell, it looks in .cshrc to initialize itself. Lines starting with hash marks are comments, so the only thing here by default is a line telling it to look in the file /etc/CSHRC to initialize itself.)

What you need to do is add the following three lines of personal customizations to the end of your .cshrc file:

alias smal ~dwjones/smalstuff/smal32.intel -U ~dwjones/hawk
alias link ~dwjones/hawk/link
alias hawk ~dwjones/hawk/hawk.intel

These lines add the commands smal, hawk and link to your environment.

After you have added these lines to to the end of your .cshrc file, exit the editor, log off the machine, and then log in again in before you test them.

If you are in 303 MLH and need to print a SMAL assembly listing files named file.l, the following print command is likely to produce the most legible results:

lp -o landscape file.l