X86-64 Divide Instruction Flashcards
When a 4 byte value is written to a 4 byte register, the upper 4bytes are set to _____
0
%eax: 0x47372000
%edx: 0x00000757
We want 8-byte result: 0x000007574372000
Shlq $32, %rdx. //shift left 5 position
Orq %rdx, %rax //can also do addq
What if multiply ushering imulw %cx giving us a 4 byte result where the lease significant 2bytes are %ax and most significant 2 bytes are %dx.
- GARBAGE can be in the upper 6 bytes in both register
- Must combine 2bytes values in %ax and %dx so we have a 4 byte value
Mild for ________, doesn’t allow for use of more than one operant and always (_________) results in our 2w bit product being split between 2 registers. And we don’t have an option to compute a w-bit product
For unsigned values, except for 1-byte products
If we are using imulX (for signed values) we have two other options
ImulX Sri, Dest
ImulX Imm, Src, Dest
But these options produce 2-bit results, so overflow is possible
Imull %edx, %eax
Mule %dx
Full 4bytes result is in %eax
4-byte results is half of %dx and half of %ax
What if we have 4-byte unsigned values
- We could use mull %edx and have our 8-byte product split between %eax and %rdx
- We could use imulY with two 8-byte operands: imulq %rdx, %rax
What if we have two byte signed values??