

Assembly Constants
There are several directives provided by NASM that define constants. We have already used the EQU directive in previous chapters. We will particularly discuss three directives:
EQU
%assign
%define
The EQU Directive
The EQU directive is used for defining constants. The syntax of the EQU directive is as follows:
For example,
You can then use this constant value in your code, like:
The operand of an EQU statement can be an expression:
Above code segment would define AREA as 200.
Example:
The following example illustrates the use of the EQU directive:
![]()
When the above code is compiled and executed, it produces fol owing result:
The %assign Directive
The %assign directive can be used to define numeric constants like the EQU directive. This directive allows redefinition. For example, you may define the constant TOTAL as:
Later in the code you can redefine it as:
This directive is case-sensitive.
The %define Directive
The %define directive allows defining both numeric and string constants. This directive is similar to the #define in C. For example, you may define the constant PTR as:
The above code replaces PTR by [EBP+4].
This directive also allows redefinition and it is case sensitive.
Describe what you're looking for in as much detail as you'd like.
Our AI reads your request and finds the best matching books for you.
Popular searches:
Join 2 million readers and get unlimited free ebooks