Search code examples
assemblycmp

what does cmp do in assembly language


I was just wondering what this does. As of now I just think that it compares %rsp with %eax but Im not really sure what the 0x10 there for

cmp    0x10(%rsp),%eax

thanks for the help


Solution

  • That is AT&T syntax for comparing the DWORD at memory location (rsp+10h) to the value in eax. The Intel syntax equivalent is:

    cmp eax,[rsp+10h]
    

    If the syntax difference is what is confusing you, check out this site which gives a good basic comparison between the two.

    BTW, comparing the value of rsp with eax would be (AT&T):

    cmp %rsp,%eax
    

    or (Intel):

    cmp eax,rsp