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 bute 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 substracts 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 and we interpret this instruction as %rax = %rbx.

False!

For 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 assambly?

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

Wrong!

The cmpq instruction is one of the instructions in which the most right element is the on the left side of the comparison, meaning that in this example, the instruction can be interpreted as 9 < rbx.

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

Correct!

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

Wrong!

The subq is interpreted as rax = rax - rbx, meaning that not the difference between rax and rbx is compared with 9, but the original value of rbx. Moreover, the cmpq instruction is interpreted as 9 < rbx, instead of rbx < 9.

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

Wrong!

As in the previous option, the subq stores the difference rax - rbx in rax and in cmpq the original value of rbx is compared with 9 instead of rbx - rax.

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