2

I have this line of assembly:

cmpb   $0x0,(%rax,%rcx,1)

Now, according to the references out there, cmpb does an immediate compare of two bytes. So it compares 0 with (%rax,%rcx,1). Can somebody explain what this second argument is / does?

Thanks!

0

2 Answers 2

8

This is the AT&T syntax for

cmp BYTE PTR [rax+rcx*1], 0

So it computes the address using rax + rcx, dereference it to obtain a byte, and then compare it with the number 0.

5

The general syntax for this type of memory operand is:

disp(base,offset,mult)

which gives you the address:

base + disp + offset*mult

So in your case (disp is 0), cmpb compares 0 and the value stored at:

%rax + (%rcx * 1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.