A.3.2 Defining variable with initial values
To allocate a variable area with a default value, use the .db directives/.db2/.dhw directives/.db4/.dw directives in the section with the default value.
In order that it may be referenced from other files as well, it is necessary to define the label with the .public directive.
Example | Defining variable with initial values |
.dseg sdata
.public _val0 ;Sets _val0 as able to be referenced from other files
.public _val1 ;Sets _val1 as able to be referenced from other files
.public _val2 ;Sets _val2 as able to be referenced from other files
.align 4 ;Aligns _val0 to 4 bytes
_val0:
.db4 100 ;Allocates a 4-byte area for _val0, and stores 100 in it
_val1:
.db2 10 ;Allocates a 2-byte area for _val0, and stores 10 in it
_val2:
.db 1 ;Allocates a 1-byte area for _val0, and stores 1 in it
|