Assignment 3, due Sep 9

Part of the homework for 22C:60 (CS:2630), Fall 2011
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

On every assignment, write your name legibly as it appears on your University ID card! Homework is due on paper at the start of class on the day indicated (usually Friday). Exceptions will be made only by advance arrangement (excepting "acts of God"). Late work must be turned in to the TA's mailbox (ask the CS receptionist in 14 MLH for help). Never push homework under someone's door!

  1. Background: Consider the following SMAL code
    .       =       0
            W       1234567890
            H       #02D2, #4996
            W       2#01001001100101100000001011010010
            W       8#11145401322
            B       #D2, 2, 8#226, 32#29
    

    A Problem: Which of the above lines, if any, assemble the same value into a word of memory? (0.5 points)

  2. Background: Consider this two-line text string formatted for output on a Windows system where lines end with a carriage return followed by a linefeed and strings are terminated by a null character:
            ASCII   "Two",CR,LF,"lines",NUL
    

    A Problem: Give SMAL definitions for the symbols CR, LF, and NUL that would make this string assemble correctly. This problem is closely related to exercise i) in Chapter 3 of the notes. (0.5 points)

  3. Background: Consider the following SMAL code:
    .       =       0
    A:      W       0
    B       =       . - 3
    C       =       D + #FFFFFFFF
    D       =       A + 3
    E:      B       0
    

    A Problem: What are the values of the 5 identifiers A, B, C, D and E. (0.5 points)

    Hints: You can get this by understanding the code (strongly recommended). You can check your answer using the SMAL assembler, either by dumping the symbol table (you get to research how to do this) or by modifying the program to use these values so you can see them in the assembler listing (you get to research how to do this).

  4. A Problem: Write SMAL code to create the following data structure: DAYTABLE is the label on the first word of an array of 7 words. Each word in DAYTABLE is the address of (is a pointer to) a null terminated string giving the name of the corresponding day of the week. So, DAYTABLE[0] points to "Sunday", DAYTABLE[1] points to "Monday", and so on. (1.0 points)

  5. A Problem: Do exercise b) from Chapter 4 of the notes. (0.5 points)