3.12 Exercises
3.1
// unsigned 16-bit hex
5ED4 - 07A4 = 5730
3.2
// signed 16-bit hex
5ED4 - 07A4 = 5730
3.3
// convert 5ED4 into a binary number
5ED4 = 0101 1110 1101 0100
3.4
// unsigned 12-bit oct
4365 - 3412 = 0753
3.5
// signed 12-bit oct
4365 - 3412 = 4753
3.6
// unsigned 8-bit dec
185 = 1011 1001
122 = 0111 1010
185 - 122 = 0011 1111 = 63
neither
3.7
// signed 8-bit dec
185 = 1011 1001
122 = 0111 1010
185 + 122 = 0011 0011
overflow
3.8
// signed 8-bit dec
185 = 1011 1001
122 = 0111 1010
185 - 122 = 1100 0001
underflow
3.9
// signed 8-bit dec num stored in two's complement
151 = 1001 0111
214 = 1101 1000
151 + 214 = 1001 0111 + 1101 1000 = 0110 1111 = 111
3.10
// signed 8-bit dec num stored in two's complement
151 = 1001 0111
214 = 1101 1000
151 - 214 = 1001 0111 - 1101 1000 = 1011 1111 = 191
3.11
// unsigned 8-bit
151 = 1001 0111
214 = 1101 1000
151 + 214 = 1001 0111 + 1101 1000 = 0110 1111 = 111
3.12
Iteration | Step | Multiplier | Multiplicand | Product |
---|
0 | Initial values | 001 010 | 110 010 | 000 000 |
1 | 1a:1=>Prod = Prod + Mcand | 001 010 | 110 010 | 110 010 |
| 2:shift left Multiplicand | 001 010 | 100 100 | 110 010 |
| 3:shift right Multiplier | 000 101 | 100 100 | 110 010 |
2 | 1a:1=>Prod = Prod + Mcand | 000 101 | 100 100 | 010 100 |
| 2:shift left Multiplicand | 000 101 | 001 000 | 010 100 |
| 3:shift right Multiplier | 000 010 | 001 000 | 010 100 |
3 | 1a:1=>Prod = Prod + Mcand | 000 010 | 001 000 | 011 100 |
| 2:shift left Multiplicand | 000 010 | 010 000 | 011 100 |
| 3:shift right Multiplier | 000 001 | 010 000 | 011 100 |
4 | 1a:1=>Prod = Prod + Mcand | 000 001 | 010 000 | 101 100 |
| 2:shift left Multiplicand | 000 001 | 100 000 | 101 100 |
| 3:shift right Multiplier | 000 000 | 100 000 | 101 100 |
5 | 1a:1=>Prod = Prod + Mcand | 000 000 | 100 000 | 001 100 |
| 2:shift left Multiplicand | 000 000 | 000 000 | 001 100 |
| 3:shift right Multiplier | 000 000 | 000 000 | 001 100 |
6 | 1a:1=>Prod = Prod + Mcand | 000 000 | 000 000 | 001 100 |
| 2:shift left Multiplicand | 000 000 | 000 000 | 001 100 |
| 3:shift right Multiplier | 000 000 | 000 000 | 001 100 |
3.13
Method as above
3.14
// if this is being done in hardware
eight time units
// if this is being done in software
twelve time units
3.15
time = log2(31) * 4 = 20
3.16
time = log2(8) * 4 = 12
3.17
0 X 33 X 0 X 55 = 0 X (32 + 1) X 0 X (64 - 9)
= 0 X (2 X 2 X 2 X 2 X 2 + 1) X 0 X (2 X 2 X 2 X 2 X 2 X 2 - (2 X 2 X 2 + 1))
3.18
I am lazy
3.19
I am lazy
3.20
// if it is a two's complement
3072
// if it is an unsigned
3072
3.21
I don't know
3.22
// if it is a floating point
s = 0
E = 65
F = 1.0
value = 1.0 x 2 ^ 65
3.23
// single precision format
63.25 = 111111.01 = 1.1111101 x 2 ^ 5
s = 0
exp = 5 + 127 = 1000 0100B
0 10000100 11111010000000000000000
3.24
// double precision format
63.25 = 111111.01 = 1.1111101 x 2 ^ 5
s = 0
exp = 5 + 1023 = 10000000100B
0 10000000100 1111101000000000000000000000000000000000000000000
后面的题不写了…