Tech notes |
|
Format of numbers into the CPU's registersThree number formats are used: 16 bits, 32 bits and 32 bits floating-point. The simplest is the 16 bits one that allows to represent a signed integer number between -32768 and +32767 where the sign is kept by the more significant bit; alternatively it allows to represent an unsigned integer number between 0 and 65535.
Into the CPU's registers, an integer is normally handled with the HL registers couple, with the more significant part in H register. In memory, an integer takes up two adjacent bytes. The byte at the lower address contains the less significant part, the one usually stored in L. The byte at the higer address contains the more significant part. The second format takes up four bytes, two integer together forming a 32 bits number, called double or long integer, which allows to represent a signed integer number between -2147483648 e +2147483647, and the sign is kept by the more significant bit of the first integer.
Into the CPU's registers, a double is normally handled with the HLDE registers double-couple, where the more significant part is in H register, and so forth, i.e. register E is the less significant byte. In memory, a double takes up four adjacent bytes, splitted in two integer, where the more significant integer (HL) is stored in the locations with the lower address, while the less significant one (DE) is stored in the locatons with higher address. Therefore onto the Stack, the more significant integer is the top of the Stack, and the other is the second accessible.
The third format requires a 32 bits double, but internally the bits are used in a different way, representing a real number approximately between -1.7 * 10^38 and +1.7 * 10^38 with a 7 digits precision. The sign is stored into the more significant bit, then a 8 bits exponent and a 23 bits mantissa follow.
Z80 register usageBC stores the instruction pointer. SP keeps the data stack pointer
|
Ultimo aggiornamento: 06-09-2002. Copyright (c) 2000-2002 Matteo Vitturi.
|