Pragmatic directives: Difference between revisions

Content added Content deleted
Line 34: Line 34:
These are common to most assemblers but syntax may vary. Place them in your source code file. As with code, all of these can be deactivated by commenting them out.
These are common to most assemblers but syntax may vary. Place them in your source code file. As with code, all of these can be deactivated by commenting them out.


* <code>@data</code>: Marks the beginning of the data segment.
* <code>.data</code>: Marks the beginning of the data segment. You can load this segment into a segment register with <code>@data</code> rather than <code>seg .data</code>.
* <code>@code</code>: Marks the beginning of the code segment.
* <code>.code</code>: Marks the beginning of the code segment. You can load this segment into a segment register with <code>@code</code> rather than <code>seg .code</code>.
* <code>equ</code>: Equates a label to a specific numeric value. Each instance of that label in your code becomes a constant if preceded by a # and a memory address otherwise.
* <code>equ</code>: Equates a label to a specific numeric value. Each instance of that label in your code becomes a constant if preceded by a # and a memory address otherwise.


Line 50: Line 50:
* <code>macro</code>: Defines a macro. Any time the macro name appears in your source document, the assembler replaces it with the definition. Any parameters supplied to the macro are also plugged in. This is useful for parameter passing which would otherwise be very tedious. Every macro must end with an <code>endm</code>.
* <code>macro</code>: Defines a macro. Any time the macro name appears in your source document, the assembler replaces it with the definition. Any parameters supplied to the macro are also plugged in. This is useful for parameter passing which would otherwise be very tedious. Every macro must end with an <code>endm</code>.


* <code>BYTE PTR</code>/<code>WORD PTR</code>: Tells the assembler that the value after this directive is a pointer to memory rather than a constant. This is useful when using labels and the command is somewhat ambiguous about the size or data type.
* <code>byte ptr</code>/<code>word ptr</code>: Tells the assembler that the value after this directive is a memory address rather than a constant. This is useful when using labels and the command you're using is somewhat ambiguous about the data size or whether this is an address or a constant.

* <code>seg</code>: When using a labeled code section or memory address as an operand, placing <code>seg</code> in front tells the assembler you wish to load the segment that memory address is located in, rather than the address itself.

* <code>offset</code>: When using a labeled code section or memory address as an operand, placing <code>offset</code> in front tells the assembler you wish to load the offset of that address from the beginning of its segment.


=={{header|Ada}}==
=={{header|Ada}}==