CSE logo University of Washington Computer Science & Engineering
 CSE 410 Computer Systems - Homework 1 - Spring 2010
  CSE Home   About Us    Search    Contact Info 

Due: Thursday, April 8, at 11 pm.

The purpose of this assignment is to get some practice with binary encodings of numbers and characters. All binary and hexadecimal integers should be treated as 16-bit numbers, 2's complement integers.

General hint: When converting between binary and decimal, it may be faster to convert to/from hexadecimal first, rather than dealing with the individual bits one by one. However, you should know how to do the conversions either way (directly from binary, or via hex numbers).

Obviously, many of these questions can be answered trivially by typing numbers into a calculator and pushing a button. Please be sure you can do them without having to rely on that.

We suggest you show your work or partial results so if your answer isn't completely correct we can fairly assign partial credit.

  1. Convert each of the following base-10 (decimal) values to binary and hexadecimal 16-bit 2's complement numbers.

    1. 42
    2. -17
    3. 32,767
    4. -32,768
    5. 1011

  2. Convert the following 16-bit, 2's complement binary numbers to hexadecimal and decimal.

    1. 0000 1000 0011 0101
    2. 0101 0000 1100 1101
    3. 1111 1110 1101 0101
    4. 1000 0000 0000 0001

  3. Convert the following 16-bit, 2's complement hexadecimal numbers to binary and decimal.

    1. 0x019a
    2. 0xff3d
    3. 0xFACE
    4. 0x1010

  4. Do the following arithmetic problems using 16-bit 2's complement numbers. The numbers are given in hexadecimal and you should give your answers in hexadecimal. You are not required to convert the numbers or the answers to decimal, but you might want to do that as a check. You should ignore overflow or underflow.

    1. 0x0017 + 0x0042
    2. 0x0017 - 0x0042
    3. 0x0BAD + 0xF00D
    4. 0x1101 - 0xff0f


  5. In C and C++ (and MIPS/SPIM), character strings are encoded using the ASCII character set, and an additional byte containing binary zero (all 0 bits) is stored after the characters in the string to indicate its end. For example, the string "Foo" would be stored in 4 bytes with the hex value 0x466f6f00.

    Give the hex values corresponding to the following strings. The surrounding quotes are not part of the value of the string. (An ASCII conversion chart is located in sec. 2.9 of the textbook, and the information is also included on the MIPS "Green Card" in the front of the book and on the course web site.)

    1. "Hi y'all!"
    2. "x+1=17?"

  6. Convert the following hex character strings to ASCII (spaces inserted for readability - not part of the hex digits)

    1. 0x4974 2773 2061 2022 7365 6372 6574 2221 2100
    2. 0x596f 7527 7265 2064 6f6e 652e 00

Turn-in Instructions: Use the turn-in drop box link on the main course web page to submit a file containing your solutions. You can use any common file format, including plain text, word, or pdf. If you wish, you could also scan in a hand-written solution and submit that, but if you do that, please be sure your handwriting is neat and legible. Please be sure to include your name at the top of your answers.


CSE logo Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA  98195-2350
(206) 543-1695 voice, (206) 543-2969 FAX
[comments to Hal Perkins]