Z80 - Basic Concepts - Answers of Exercises
Z80 - Basic Concepts - Answers of Exercises
Exercise 1.3:
19/2 = 9 remains 1 1
9/2 = 4 remains 1 1
4/2 = 2 remains 0 0
2/2 = 1 remains 0 0
1/2 = 0 remains 1 1
Exercise 1.4:
101
+ 1010
= 1111 = 20 + 21 + 22 + 23
= 15
127/2 = 63 remains 1 1
63/2 = 31 remains 1 1
31/2 = 15 remains 1 1
15/2 = 7 remains 1 1
7/2 = 3 remains 1 1
3/2 = 1 remains 1 1
1/2 = 0 remains 1 1
Exercise 1.10: Largest number in 7 bits is 28-1, which is 127. Smallest number in one's complement is -(28-
1), which is -127. The smallest two's complement is even 1 smaller: -(28-1 + 1), which is -128.
20/2 is 10 remainder 0 0
10/2 is 5 remainder 0 0
5/2 is 2 remainder 1 1
2/2 is 1 remainder 0 0
1/2 is 0 remainder 1 1
22 + 24 = 4 + 16
= 20
Exercise 1.12:
Exercise 1.13: No, because the result has a magnitude that is always less then 128, so that will always fit
into seven bits.
Exercise 1.14:
Exercise 1.16:
"29" is in packed BCD "00101001"
"91" is in packed BCD "10010001"
Exercise 1.17: No, because the four bits "1010" of the first BCD digit is not valid; it is one of the six unused
bit combinations.
Exercise 1.18:
BCD: 0000 0101 0001 0010 0011 0001 0010 0011
23123 in binary: 0101 1010 0101 0011
-23123 in two's complement: 1010 0101 1010 1101
Exercise 1.19:
Exercise 1.22:
Exercise 1.23:
Exercise 1.24:
Exercise 1.29:
in direct binary
1024 is 210, which is in signed binary 00000100 00000000
in two's complement
Exercise 1.30: The V-bit is the overflow bit, which shows if a signed number has changed sign after an
operation unintentionally. In practice, the overflow should only be acted upon in two's complement
representation, and can be ignored in direct (unsigned) binary representation.
Exercise 1.31:
Exercise 1.32: 4D 45 53 53 41 47 45
M 4D
E 45
S 53
S 53
A 41
G 47
E 45