Assembly: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
Chase (talk | contribs)
m Source syntax highlighting
Line 14:
== Assembly Syntax ==
In assembly, every instruction (or operation/operator/opcode) is followed by a comma-separated list of parameters (or operands). These operands can be either immediate values (i.e. numbers such as 1, 2, [[Hexadecimal Notation|0x]]16, 0101[[Binary Notation|b]]), or registers, or a memory location. For example,
<source lang="asm">
mov eax, 123
</source>
The instruction is mov, the operands are eax and 123. Here eax is a register and 123 is an immediate value.
 
Line 21 ⟶ 23:
=== Intel Syntax ===
Generally speaking, the first operand of an operation is the destination operand, and the other operand (or operands) is the source operand. For example:
<source lang="asm">
mov eax, 123
</source>
The mov instruction takes a value from the source operand, and places it in the destination operand, so the value 123 would be placed into the register eax. The Intel syntax is used by Intel in all documentation, descriptions and examples. Also, the Intel syntax is used in most [[online assembly tutorials]] because of the majority of those tutorials were written when [[TASM]] (which uses the Intel syntax) was the dominent assembler.
 
Line 28 ⟶ 32:
=== AT&T Syntax ===
AT&T syntax is the reverse of Intel syntax. The data operated on moves from left to right. Here is the same statement as above in AT&T syntax.
<source lang="asm">
mov $123, %eax
 
</source>
There are also some other differences with operands: