Section Exercises
True or False
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 somelabelWrong!
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 somelabelCorrect!
subq %rbx, %rax
cmpq %rbx, $9
jl somelabelWrong!
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 somelabelWrong!
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?
Last updated