Here is some assembly code in Intel syntax:
// Jump to done if rsi >= rax.
cmp rsi, rax
jae done
This makes sense to my brain: you jump if rsi is "above or equal to" rax,
matching the order of arguments in the cmp
instruction. Compare this to the
GNU syntax:
// Jump to done if rsi >= rax.
cmp %rax, %rsi
jae done
This hurts my brain every time. It doesn't help that when I come to this fresh
after awhile not writing assembly code I go to look up the semantics of cmp
and jae
in the Intel manual and find that it's all stated in terms of "first"
and "second" operand, which doesn't match what I'm seeing on the screen in
front of me.
End complaining. My questions:
Is there some other way to express cmp
or jae
to the GNU assembler so
that the order of operands to cmp
matches the logical comparison referred to
by jae
?
Assuming the answer to (1) is no, does anybody have a good way for me to look at this so that I can remember how it works next time? Anything better than "GNU does it backwards"?
Note that I'm not asking how to use Intel syntax with the GNU assembler; I'm aware that's possible. I'm working in an existing GNU syntax codebase, and am asking for some mnemonic or other way to help me keep this straight in my head.
In GAS you can use .intel_syntax noprefix
to get the syntax you're more familiar with, but you can't just swap them around in AT&T syntax.
I'd say keep in mind that in Intel syntax mov x,y
means 'make x equal to y' whereas in AT&T syntax it's 'copy x into y', once you have that convention down expand it to other instructions you come across.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With