|
|
Basics
Extension of sign
|
|
This question always comes on when the quantity of source information
is less than destination's capacity. This is a very typical situation
because we often want to save "short" information into "large" register
(for example, one byte or
wyde
into octabyte register). The problem is what
to do with the "unused" left bits of the destination.
It first comes to our mind that they must be reset to zero. But this
evident decision is correct only for unsign numbers.
But if the number contains sign bit, the picture becomes
more complex.
In negative numbers the leftmost bits are usually 1s, but not 0s. So
in the signed case all left "unused" bits are filled by the value of the
source sign bit. In other words for positive numbers when the sign is
reset, zero value is used for filling, but for negative ones the most significant
bits will be set to 1.
Here is the picture how it works:
Some concrete examples:
source | destination (unsigned 64 bit) | destination (signed 64 bit) |
---|
byte | + |
41 | 00 00 00 00 00 00 00 41 |
00 00 00 00 00 00 00 41 |
byte | - |
81 | 00 00 00 00 00 00 00 81 |
FF FF FF FF FF FF FF 81 |
wyde | + |
40 01 | 00 00 00 00 00 00 40 01 |
00 00 00 00 00 00 40 01 |
wyde | - |
80 01 | 00 00 00 00 00 00 80 01 |
FF FF FF FF FF FF 80 01 |
tetra | + |
40 00 00 01 | 00 00 00 00 40 00 00 01 |
00 00 00 00 40 00 00 01 |
tetra | - |
80 00 00 01 | 00 00 00 00 80 00 00 01 |
FF FF FF FF 80 00 00 01 |
octa | + |
40 00 00 00 00 00 00 01 | 40 00 00 00 00 00 00 01 |
40 00 00 00 00 00 00 01 |
octa | - |
80 00 00 00 00 00 00 01 | 80 00 00 00 00 00 00 01 |
80 00 00 00 00 00 00 01 |
Note that there is no difference between signed and unsigned data for full
octabyte code - it's just no "free" left bits in this case.
Related topics:
"MMIX basics" page
|
(C) 2001, Evgeny Eremin. rEd-MMI project documentation
|
|