Write your solutions to problems 1-9 on paper. Use the algorithms presented in class and show your work.
1. Convert the following numbers to their 32-bit binary representations. Assume that 2's complement is used for negative numbers. Express your answers in hexadecimal.
a. 1985
b. -4000
c. 8192
2. What decimal numbers are represented by the following 32-bit
values? (Again, assume that 2's complement is used for
negative numbers.)
a. 0000003D
b. 000010B6
c. FFFFFABC
3. Tanenbaum, problem 7, p. 689.
4. Tanenbaum, problem 9, p. 689.
5. Tanenbaum, problem 14, p. 690.
6. Tanenbaum, problem 1, p. 698.
7. Tanenbaum, problem 2, p. 698.
8. Tanenbaum, problem 5, p. 699.
9. Write Java expressions to do the following:
(Assume x and y are declared as ints.
Bits are numbered 31 to 0 from left to right.)
a. Set y to the value in bits 17-10 of x.
b. Set bits 17-10 of x to 0.
c. Set bits 17-10 of x to 1.
d. Invert bits 17-10 of x.
e. Store the value '0110' in bits 19-16 of x.
Programming problems (due February 19 at midnight; use
handin)
1. On the MIPS architecture, machine language instructions
are encoded in 32-bit words. The format for instructions
which access memory consists of four fields, as shown below:

Write a program which takes a MIPS instruction, encoded as a
hexadecimal number, as its single command-line argument, and
extracts these four fields. Print each one on a separate
line of output. Print the opcode as a 6-bit binary value
(including leading zeros if applicable), the rs and rt fields as
decimal integers, and the address in hexadecimal. For
example,
input:
java Mips 68ec871c
output:
opcode: 011010
rs: 7
rt: 12
address: 871c
2. Write a Java program with one command-line argument, an
integer expressed in decimal. The program should print the
number in both decimal and hexadecimal, then reverse the hex
digits in the number and print it again in both decimal and
hexadecimal. Perform the reversal at the binary level, not by applying string
operations. For example,
input:
java Reverse -5
output:
x (base 10): -5
x (base 16): fffffffb
x reversed (base 10): -1073741825
x reversed (base 16): bfffffff
input:
java Reverse 934892812
output:
x (base 10):
934892812
x (base 16): 37b9550c
x reversed (base 10): -1068131469
x reversed (base 16): c0559b73