Arithmetic constants
The assembler language provides arithmetic constants dependent upon the assembly mode.
The assembler language provides four kinds of arithmetic constants:
- Decimal
- Octal
- Hexadecimal
- Floating point
In 32-bit mode, the largest signed positive integer number that can be represented is the decimal value (2**31) - 1. The largest negative value is -(2**31). In 64-bit mode, the largest signed positive integer number that can be represented is (2**63)-1. The largest negative value is -(2**63). Regardless of the base (for example, decimal, hexadecimal, or octal), the assembler regards integers as 32-bit constants.
The interpretation of a constant is dependent upon the assembly mode. In 32-bit mode, the AIX® assembler behaves in the same manner as earlier AIX® versions: the assembler regards integers as 32-bit constants. In 64-bit mode, all constants are interpreted as 64-bit values. This may lead to results that differ from expectations. For example, in 32-bit mode, the hexadecimal value 0xFFFFFFFF is equivalent to the decimal value of "-1". In 64-bit mode, however, the decimal equivalent is 4294967295. To obtain the value "-1" the hexadecimal constant 0xFFFF_FFFF_FFFF_FFFF (or the octal equivalent), or the decimal value -1, should be used.
In both 32-bit and 64-bit mode, the result of integer expressions may be truncated if the size of the target storage area is too small to contain an expression result. (In this context, truncation refers to the removal of the excess most-significant bits.)
To improve readability of large constants, especially 64-bit values, the assembler will accept constants containing the underscore ("_") character. The underscore may appear anywhere within the number except the first numeric position. For example, consider the following table:
Constant Value | Valid/Invalid? |
---|---|
1_800_500 | Valid |
0xFFFFFFFF_00000000 | Valid |
0b111010_00100_00101_00000000001000_00 | Valid (this is the "ld 4,8(5)" instruction) |
0x_FFFF | Invalid |
The third example shows a binary representation of an instruction where the underscore characters are used to delineate the various fields within the instruction. The last example contains a hexadecimal prefix, but the character immediately following is not a valid digit; the constant is therefore invalid.