Dip in to ATT syntax

There are 2 syntaxes that mainly used in reverse engineering. Intel and ATT. First I thought ATT was hard to read and Intel was a clean assembly syntax. But I was wrong. ATT reduces the time and abstraction by little changes in the code that It’ll be easier for humans to read. This will be a small article how to read or what is changed in ATT.

To reverse a binary in ATT syntax we have to configure radare. First load the binary file to decompile by

$ r2 -d binaryname

Then analyze the file first.

>afl Then run the command for changing the syntax >e asm.syntax=att

We can see in addition to intel syntax mov,push there is a extra character in the end like movl,pushq.

What does that mean ? well if we see the full syntax of a one line in intel syntax mov qword [local_18h],rax and then the same line in ATT syntax movq %rax,local_18h.

  • First mov qword is turned into movq
  • In intel syntax mov size Destination,Source and in mov{size letter} Source,Destination
  • And also transferring constants(which are prefixed using the $ operator) e.g. movq $3 rax would move the constant 3 to the register in Intel its just the constant.
Suffixes for data types
Intel Data TypeATT Suffix Size in bytes
Byteb1
Wordw2
Double Wordl4
Quad Wordq8
Single Precisions4
Double Precisionl8
Some instructions in ATT syntax
  • leaq source, destination: this instruction sets destination to the address denoted by the expression in source
  • addq source, destination: destination = destination + source
  • subq source, destination: destination = destination – source
  • imulq source, destination: destination = destination * source
  • salq source, destination: destination = destination << source where << is the left bit shifting operator
  • sarq source, destination: destination = destination >> source where >> is the right bit shifting operator
  • xorq source, destination: destination = destination XOR source
  • andq source, destination: destination = destination & source
  • orq source, destination: destination = destination | source
Jump instructions and testing for values

As you know there is no fancy if statements in assembly but testing and comparing values of variables. There are 2 instructions that does this.

  • cmpq source2, source1: it is like computing a-b without return the value
  • testq source2, source1: it is like computing a&b without returning the value

Jump values are used to control the flow of the program just like if conditions does.

Jump TypeDescription
jmpUnconditional Jump, jump forcefully
jeEqual/Zero, Jump if equal
jneNot Equal/Not Zero , Above but not equal
jsNegative
jnsNonnegative
jgGreater
jgeGreater or Equal
jlLess
jleLess or Equal
jaAbove(unsigned)
jbBelow(unsigned)

This is the End!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.