# C335 Homework #2

\$30.00

## Description

PART I (4 POINTS)
Do the addition and subtraction manually for the following two binary numbers:
1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0
+ 0 0 1 1 0 1 1 0 1 0 1 1 – 0 0 1 1 0 1 1 0 1 0 1 1
——————————— ——————————–
PART II (4 POINTS) (SHOW YOUR STEPS!)
(1) What binary number does this hexadecimal number represent: 0x7ffffffa? What decimal
number does it represent? (assume 32-bit 2’s complement)
(2) What hexadecimal number does the binary number present:
0b11001010111111101111101011001110?
PART III (4 POINTS)
(1) Convert -10310 to binary (8 bits), and then to hexadecimal (assume 2’s complement is
used).
(2) Convert 0xAA to binary then to Decimal (assume 2’s complement is used).
PART IV (TOTAL 12 POINTS, 3 POINTS EACH) (SHOW YOUR STEPS!)
(1) Convert 4096 into a 32-bit two’s complement binary number.
(2) Convert -2047 into a 32-bit two’s complement number.
(3) What decimal number does this two’s complement binary number represent: 0b1111
1111 1111 1111 1111 1111 0000 0110?
(4) What decimal number does this two’s complement binary number represent: 0b1111
1111 1111 1111 1111 1111 1110 1111?
Assume that \$a0 and \$a1 are used for the input and both initially contain the integers a and b,
respectively. Assume that \$v0 is used for the output:
loop: beq \$a1, \$zero, finish
j loop
The following code segment processes two arrays and products an important value in register
\$v0. Assume that each array consists of 2500 words indexed 0 through 2499, that the base
addresses of the arrays are stored in \$a0 and \$a1, respectively, and their sizes (2500) are stored
code does. Specifically, what will be returned in \$v0?
sll \$a2, \$a2, 2
sll \$a3, \$a3, 2
lw \$t4, 0(\$t4)
lw \$t3, 0(\$t3)
bne \$t3, \$t4, skip
bne \$t1, \$a3, inner
bne \$t0, \$a2, outer
PART VII (6 POINTS)
The following program tries to copy words from the address in register \$a0 to the address in
register \$a1, counting the number of words copied in register \$v0. The program stops copying
when it finds a word equal to 0. You do not have to preserve the contents of register \$v1, \$a0,
and \$a1. This terminating word should be copied but not counted.
addi \$v0, \$zero, 0 # Initialize count
loop:lw \$v1, 0(\$a0) # Read next word from source
sw \$v1, 0(\$a1) # Write to destination