Use the division method to convert each of the following numbers from decimal to eight-bit 2's complement hexadecimal numbers (if I were to be obnoxiously pedantic, the phrase "2's complement hexadecimal" would be incorrect. Why? because technically it's 16's complement)
Old | Old/16 | Old % 16 |
---|---|---|
43 | 2 | 11 |
2 | 0 | 2 |
Old | Old/16 | Old % 16 |
---|---|---|
37 | 2 | 5 |
2 | 0 | 2 |
Original: | 25 |
Invert the bits: | da |
Add one: | db |
Old | Old/16 | Old % 16 |
---|---|---|
193 | 12 | 1 |
12 | 0 | 12 |
Use the multiplication method to convert each of the following numbers from eight-bit 2's complement binary to decimal.
00110101
The number is positive, since the sign bit is 0.
Old | Bit | New |
---|---|---|
0 | 1 | 1 |
2 | 1 | 3 |
6 | 0 | 6 |
12 | 1 | 13 |
26 | 0 | 26 |
52 | 1 | 53 |
11011010
The number is negative since its sign bit is 1; we have to start by finding its magnitude
Original: | 11011010 |
Invert the bits: | 00100101 |
Add one: | 00100110 |
Now we can convert to decimal.
Old | Bit | New |
---|---|---|
0 | 1 | 1 |
2 | 0 | 2 |
4 | 0 | 4 |
8 | 1 | 9 |
18 | 0 | 18 |
36 | 1 | 37 |
Since the number is negative, the result is -37.
0111
The number is positive, so we don't need to invert it.
Old | Bit | New |
---|---|---|
0 | 1 | 1 |
2 | 1 | 3 |
6 | 1 | 7 |
We can just 0-extend. If the most significant bit had been a 1, it would have been ambiguous as to whether it should 0-extended or 1-extended; in that case, it would have been a symptom of a typo in the assignment....
Convert each of the following numbers from binary to hexadecimal.
00111001
39
11000111
c7
001110
0e
We adopt the convention of taking the bits right to left and 0-filling. Note that in a fraction we adopt the opposite convention and go left to right; in fact, the "real" convention is that we work from the binary point out.
Convert each of the following numbers from hexadecimal to binary.
a3f
1010 0011 1111
01d
0000 0001 1101
aaa
1010 1010 1010
Perform the following hexadecimal additions. If the operation were performed on an eight-bit microprocessor, what would be the contents of the resulting NZVC condition codes?
1 | ||||
12 | 12 | ac | ac | |
+12 | +79 | +42 | +ac | |
24 | 8b | ee | 58 | |
N: | 0 | 1 | 1 | 0 |
Z: | 0 | 0 | 0 | 0 |
V: | 0 | 1 | 0 | 1 |
C: | 0 | 0 | 0 | 1 |
Perform the following binary multiplications
10010011 | 10101110 |
x01101101 | x10101110 |
10010011 | 00000000 |
00000000 | 10101110 |
10010011 | 10101110 |
10010011 | 10101110 |
00000000 | 00000000 |
10010011 | 10101110 |
10010011 | 00000000 |
00000000 | 10101110 |
0011111010010111 | 0111011001000100 |
Perform the following binary divisions
1101111 / 00010110
101 | |
00010110) | 1101111 |
10110 | |
01011 | |
00000 | |
10111 | |
10110 | |
1 |
1101000 / 110
10001 | |
110) | 1101000 |
110 | |
001 | |
000 | |
010 | |
000 | |
100 | |
000 | |
1000 | |
110 | |
10 |