A.3.2 Defining variable with initial values
To allocate a variable area with a default value, use the .DB directives/.DB2 directives/.DB4 directives in the section with the default value.
See "8.4 ROMization" for variable with initial values.
In order that it may be referenced from other files as well, it is necessary to declare 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 2 ;Aligns _val0 to 2 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 _val1, and stores 10 in it
_val2:
.DB 1 ;Allocates a 1-byte area for _val2, and stores 1 in it
|