SLAU131Y October 2004 – June 2021
Initialize 16-Bit Integers
.half value1[, ... , valuen ]
.short value1[, ... , valuen ]
.uhalf value1[, ... , valuen ]
.ushort value1[, ... , valuen]
The .half and .short directives place one or more values into consecutive halfwords in the current section. A value can be either:
The assembler truncates values greater than 16 bits.
If you use a label with .half or .short, it points to the location where the assembler places the first byte.
These directives perform a word (16-bit) alignment before data is written to the section.
When you use .half or .short in a .struct/.endstruct sequence, they define a member's size; they do not initialize memory. For more information, see the .struct/.endstruct/.tag topic.
In this example, .half is used to place 16-bit values (10, -1, abc, and a) into consecutive halfwords in memory; .short is used to place 16-bit values (8, -3, def, and b) into consecutive halfwords in memory. The label STRN has the value 100ch, which is the location of the first initialized halfword for .short.
1 0000 .space 100h * 16
2 1000 000A .half 10, -1, "abc", "a'
1002 FFFF
1004 0061
1006 0062
1008 0063
100a 0061
3 100c 0008 STRN .short 8, -3, "def", 'b'
100e FFFD
1010 0064
1012 0065
1014 0066
1016 0062