There are two main syntaxes for Assembly Language: AT&T and Intel. The former was invented by AT&T Labs in 1960's and is used on all UNIX-based systems, the original intention was to preserve portability and compatibility between different UNIX flavors. The latter was invented by Intel and is commonly used in MS systems. I have a bit of a chicken'n'egg problem here, as I have no idea who ripped off the most part from the other party but it's not relevant nor important here... The main differences between the syntax are as follows:
| Intel | AT&T |
| Mnemonics are case-insensitive | Mnemonics are lowercase |
| case insensitive registers in form of AH, ax, Eax | lowercase registers are preceded with % (percent) sign, as in %eax, %ax |
Memory operands are prefixed with size accordingly:
| machine instructions end with one of three possible suffixes:
|
| The programmer first specifies the destination and then the source operand. "mov bx, ax" moves ax to bx | You first specify the source and then the destination operand. "movw %ax, %bx" will move %ax to %bx. |
| Immediate operands, like numbers or memory addresses, are entered with "h", "b", or no suffix at all for hex, binary or decimal digits respectively | Immediate operands are preceded by $ (dollar sign). |
| Comment is denoted by a ; (colon) | A comment is denoted by a # (hash) |
| Jump and call operands are undelimited | Jumps and calls are prefixed by an * (asterisk) |
...so that the same C program (main.c), that only returns 0 to the environment would look like this:
| AT&T | C | Intel |
|
|
|
Sources:
http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/gnu-assembler/i386-syntax.html
http://en.wikipedia.org/wiki/Unix

0 comments:
Post a Comment