Assembly - Variables
Assembly - Variables
Assembly - Variables
Assembly - Variables
NASM provides various define directives for reserving storage space for variables.
The define assembler directive is used for allocation of storage space. It can be used
to reserve as well as initialize one or more bytes.
Where, variable-name is the identifier for each storage space. The assembler
associates an offset value for each variable name defined in the data segment.
choice DB 'y'
number DW 12345
neg_number DW -12345
big_number DQ 123456789
real_number1 DD 1.234
real_number2 DQ 123.456
https://www.tutorialspoint.com/assembly_programming/assembly_variables.htm 1/4
6/15/24, 3:49 PM Assembly - Variables
section .data
choice DB 'y'
When the above code is compiled and executed, it produces the following result −
https://www.tutorialspoint.com/assembly_programming/assembly_variables.htm 2/4
6/15/24, 3:49 PM Assembly - Variables
Directive Purpose
Multiple Definitions
You can have multiple data definition statements in a program. For example −
Multiple Initializations
The TIMES directive allows multiple initializations to the same value. For example, an
array named marks of size 9 can be defined and initialized to zero using the
following statement −
marks TIMES 9 DW 0
The TIMES directive is useful in defining arrays and tables. The following program
displays 9 asterisks on the screen −
https://www.tutorialspoint.com/assembly_programming/assembly_variables.htm 3/4
6/15/24, 3:49 PM Assembly - Variables
section .data
stars times 9 db '*'
When the above code is compiled and executed, it produces the following result −
*********
https://www.tutorialspoint.com/assembly_programming/assembly_variables.htm 4/4