Search code examples
att

Understand what a command does


I'm learning x86 syntax.

I've stumbled across this command which I don't seem to be sure what it does:

cmpl $0x0,%cs:0x6574

I know cmp just compares the difference and sets the flags. And the l to indicate that unsigned values are being compared.

My question is:

What are we comparing ?
The value in 0x0 against what value %cs:0x6574 ?
cs register contains an address, should I add 0x6574 to it and extract the value ? something like:

mem[cs+0x6575] 

Thanks in advance!


Solution

  • Assuming this is from real mode code it is default segment override. So instead of implicit DS use CS segment. In real mode address calculation is a bit different. Value of segment is first multiplied by 16 and than offset is added.

    So in your notation it will be

    mem[16*cs+0x6575]