Section Exercises

True or False

We use the b termination for an instruction to indicate that we access 2 bytes.

False!

The b termination of an instruction, such as movb, indicates that one byte of data is accessed.

We use the q termination for an instruction to indicate that we access 8 bytes.

True!

q stands for "quadword", which means 8 bytes.

subl %eax, %ebx is read like eax - ebx.

False!

The sub instruction subtracts the source operand from the destination operand, so this line would be read as ebx - eax.

In movq %rax, %rbx, rax is the destination and rbx is the source, so we interpret this instruction as rax = rbx.

False!

For a mov instruction, the first operand is the source and the second is the destination, so rax is the source and rbx is the destination. As a result, the instruction is interpreted as rbx = rax.

Multiple Choice

We have some values in rax and rbx. How do you check if their difference (rbx - rax) is smaller than the value 9 in AT&T Assembly?

subq %rax, %rbx 
cmpq %rbx, $9 
jl somelabel
subq %rax, %rbx 
cmpq $9, %rbx 
jl somelabel
subq %rbx, %rax 
cmpq %rbx, $9 
jl somelabel
subq %rbx, %rax 
cmpq $9, %rbx 
jl somelabel

What postfix is used for instructions using registers such as ax, di, bp?

w

Correct!

The ax, di, and bp registers store 16 bits of data (2 bytes), so we need w which stands for "word".

b

Wrong!

l

Wrong!

q

Wrong!

Last updated