X86-64 Multiply Instruction Flashcards
Multiplying any 2 numbers represented with w bits, we must store result in ______ bits to avoid overflow
2w
There are two different instructions to accomplish multiplication. ____ for signed interpretations and_____ for unsigned interpretations
ImulX, mulX
ImulX src
Result in 2w bits relative to suffix
ImulX
Result in w bits equivalent to suffix
ImulX Imm, Src, Destiny
Result in w bits equvivalent to suffix
ALU uses _____ 8-byte registers to accomplish 16-byte result
Two
This only works with ____/____ register pair. No other register pairs can be used
%rdx, %rax
Code for 128 bit unsigned multiply
# dest in %rdi, x in %rsi, y in %rdx
Movq %rsi, %rax
Mule %rdx
Movq %rax, (%rdi) -> YOU CAN ALSO MOVE VALUE TO ADRESS IN MEMORY
Movq %rdx, 8(%rdi)
If we have two-byte values that we multiple together using mule %cx giving us a 4 byte results were the least significant 2 bytes are in %ax and the most significant 2 bytes are in do then
1. ___ can be in the upper 6 bytes in both %rax and %rdx register
2. We must _____ the 2 byte values in %ax and %dx also we have a 4 byte value we can use!
Garbage, combine
%ax: 0x1234, assume %eax = 0x784f1234
%dx0056 assume %edx = 0xab330056
Want 4 byte rental 0x00561234
Shll $16, %edx. %edxL 0x00560000
Movzwl %ax, %eax. %eax: 0x00001234
Orl %edx, %eax. —> 0x00561234