Assignment 2, due Jan 30

Part of the homework for CS:2630, Spring 2015
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. A problem: Convert the following decimal numbers to unsigned 8-bit binary numbers: (0.1 points each)

    a) 100
    b) 120
    c) 140
    d) 160
    e) 170

  2. A problem: Consider the following 8-bit 2's complement binary numbers. Convert each of them to conventional signed decimal form: (0.1 points each)

    a) 01100100
    b) 01111000
    c) 10001100
    d) 10100000
    e) 10101010

  3. A problem: Consider the following decimal numbers. Convert each of them to 8-bit 1's complement binary form: (0.1 points each)

    a) 100
    b) 120
    c) -115
    d) -95
    e) -85

  4. A problem: Consider the following 8-bit binary numbers. Express each in hexidecimal: (0.1 points each)

    a) 01100100
    b) 01111000
    c) 10001100
    d) 10100000
    e) 10101010

  5. Background: Here is a quotation from machine problem 1, with line numbers added for reference:
    14  ITEM1:  W       TEXT1           ; pointer to text
    15          H       5               ; X = 5
    16          H       1               ; Y = 1
    17  
    18  ITEM2:  W       TEXT2
    19          H       2, 1            ; an alternative compacted form
    20  
    21  ITEM3:W SOMETEXT
    22  H 2,2; don't write code like this, it works but it's hard to read
    23  SOMETEXT:ASCII"world",0
    24  
    25  TEXT1:  ASCII   "lo", 0
    26  TEXT2:  ASCII   "Hel", 0
    

    Lines 18-19 are in a style different from that of lines 14-16. Lines 21-23 are a deliberate example of horrible abuse of programming style.

    A problem: Rewrite lines 18-26 so that the style is consistent with the style used in lines 14-17. Your code need not put data into memory in the same order as the original, but it should mean the same thing in the context of machine problem 1. Legible and neat handwritten work is acceptable on this assignment. (1 point)