I am curious about this constant padding by hardware.
Suppose you have a statement that says load 1 to register, say A. Your code can say that, but when the assembler generates executable code, it has to represent the number 1 as something, I mean a value stored in executable with some width. Doesn't the width have to be the size of the register you are loading?
On x86, you can operate on signed 8-bit immediate (or literal) data and produce an 8-, 16-, or 32-bit result. Or you can use 16- or 32-bit immediates. On x86-64, you can also produce 64-bit results.
I seem to recall that 386 has special instructions to load only low portion of a register. So if this instruction is used, you have loaded the low portion of the register, say only 8 or 16 bit representation of number one, but what happens to the high part of the register, especially if you want to use the number if full 32 or 64 bit operations?
On x86 or x86-64, 8- or 16-bit operations only modify that much of a register, but on x86-64, 32-bit results are zero-extended into a 64-bit register. |