X86-64 Divide Instruction Flashcards

1
Q

When a 4 byte value is written to a 4 byte register, the upper 4bytes are set to _____

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

%eax: 0x47372000
%edx: 0x00000757

We want 8-byte result: 0x000007574372000

A

Shlq $32, %rdx. //shift left 5 position
Orq %rdx, %rax //can also do addq

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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.

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

For unsigned values, except for 1-byte products

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

If we are using imulX (for signed values) we have two other options

A

ImulX Sri, Dest
ImulX Imm, Src, Dest

But these options produce 2-bit results, so overflow is possible

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Imull %edx, %eax
Mule %dx

A

Full 4bytes result is in %eax
4-byte results is half of %dx and half of %ax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What if we have 4-byte unsigned values

A
  1. We could use mull %edx and have our 8-byte product split between %eax and %rdx
  2. We could use imulY with two 8-byte operands: imulq %rdx, %rax
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What if we have two byte signed values??

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly