SPRUI03E June 2015 – January 2023
Initialize 16-Bit Integers
.half value1[, ... ,valuen ]
.short value1[, ... ,valuen ]
.uhalf value1[, ... ,valuen ]
.ushort value1[, ... ,valuen ]
The .half, .uhalf, .short, and .ushort directives place one or more values into consecutive halfwords in the current section. Each value is placed in a 2-byte memory location by itself. A value can be either:
The assembler truncates values greater than 16 bits.
If you use a label with .half, .short, .uhalf, or .ushort; it points to the location where the assembler places the first byte.
These directives perform a halfword (16-bit) alignment before data is written to the section. This guarantees that data resides on a 16-bit boundary.
When you use .half, .short, .uhalf, or .ushort 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 00000000 .space 100h * 16
2 00001000 0000000A .half 10, -1, "abc", 'a'
00001002 0000FFFF
00001004 00000061
00001006 00000062
00001008 00000063
0000100a 00000061
3 0000100c 00000008 STRN .short 8, -3, "def", 'b'
0000100e 0000FFFD
00001010 00000064
00001012 00000065
00001014 00000066
00001016 00000062