AT&T Instructions Flashcards

(36 cards)

1
Q

Q: What does the mov instruction do in AT&T syntax?

A

A: Copies data from the source to the destination.
Ex. mov %rax, %rbx copies the value in %rax into %rbx.

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

Q: How do you load from memory into a register in AT&T syntax?

A

A: Put the address in parentheses.
Ex. mov (%rbx), %al loads 1 byte from the address in %rbx into %al.

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

Q: How do you move an immediate value into a register in AT&T syntax?

A

A: Use $ before the immediate.
Ex. mov $123, %eax puts 123 into %eax.

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

Q: What does the lea instruction do in AT&T syntax?

A

A: Computes an address and loads it into a register (no memory access).
Ex. lea 8(%rbp), %rax puts the address %rbp+8 into %rax.

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

Q: What does add do in AT&T syntax?

A

A: Adds the source to the destination and stores the result in the destination.
Ex. add %rbx, %rax → %rax = %rax + %rbx.

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

Q: What does sub do in AT&T syntax?

A

A: Subtracts the source from the destination and stores the result in the destination.
Ex. sub $16, %rsp → %rsp = %rsp - 16.

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

Q: What does inc do?

A

A: Increments (adds 1) to the operand.
Ex. inc %rcx → %rcx = %rcx + 1.

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

Q: What does cqto do?

A

A: Sign-extends %rax into %rdx for division.

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

Q: What does imul do?

A

A: Signed multiply.
Ex. imul %rbx, %rax → %rax = %rax * %rbx.

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

Q: What does idiv do?

A

A: Signed divide (rdx:rax) / src. Quotient in %rax, remainder in %rdx.
Ex. idiv %rbx.

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

Q: What does and do?

A

A: Bitwise AND of source and destination.
Ex. and %rbx, %rax → %rax = %rax & %rbx.

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

Q: What does or do?

A

A: Bitwise OR of source and destination.
Ex. or $1, %rax sets the least significant bit of %rax.

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

Q: What does xor (or xorl) do?

A

A: Bitwise XOR. Common trick: xorl %eax, %eax sets %eax to zero.

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

Q: What does not do?

A

A: Bitwise NOT (inverts bits).
Ex. not %rax.

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

Q: What does shl do?

A

A: Logical left shift.
Ex. shl $2, %rax → %rax «= 2.

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

Q: What does shr do?

A

A: Logical right shift (fills with zeros).
Ex. shr $1, %rax → %rax»_space;= 1.

15
Q

Q: What does jmp do?

A

A: Unconditional jump to a label.
Ex. jmp my_label.

16
Q

Q: What does cmp do?

A

A: Compares source and destination (dest - src) and sets flags, but does not store a result.
Ex. cmp $10, %rax.

17
Q

Q: What does je do?

A

A: Jump if equal (ZF = 1).

18
Q

Q: What does jne do?

A

A: Jump if not equal (ZF = 0).

19
Q

Q: What does jg do?

A

A: Jump if greater (signed) → ZF=0 and SF=OF.

20
Q

Q: What does jge do?

A

A: Jump if greater or equal (signed) → SF=OF.

21
Q

Q: What does jl do?

A

A: Jump if less (signed) → SF≠OF.

22
Q

Q: What does jle do?

A

A: Jump if less or equal (signed) → ZF=1 or SF≠OF.

23
Q: What does ja do?
A: Jump if above (unsigned) → CF=0 and ZF=0.
24
Q: What does jb do?
A: Jump if below (unsigned) → CF=1.
25
Q: What does push do?
A: Decrements %rsp and stores the value on the stack. Ex. push %rbp.
26
Q: What does pop do?
A: Loads the top value from the stack into the operand and increments %rsp. Ex. pop %rbp.
27
Q: What does call do?
A: Pushes the return address on the stack and jumps to the function. Ex. call print_message.
28
Q: What does ret do?
A: Pops the return address from the stack and jumps to it (returns from function).
29
Q: How are function arguments passed in System V AMD64 ABI?
A: First six integer/pointer args: %rdi, %rsi, %rdx, %rcx, %r8, %r9. Return values in %rax.
30
Q: What does %rip hold?
A: The address of the next instruction (instruction pointer).
31
Q: What is the ZF flag in x86-64?
A: Zero Flag — set if the result of the last operation is 0.
32
Q: What is the SF flag in x86-64?
A: Sign Flag — set if the result of the last operation is negative.
33
Q: What is the CF flag in x86-64?
A: Carry Flag — set if a carry or borrow occurred in the last operation.
34