MPASM Assembler/MPLINK Object Linker Help Previous Next

MPASM Assembler : Expression Syntax and Operation : Numeric Constants and Radix

Numeric Constants and Radix
MPASM assembler supports the following radix forms for constants: hexadecimal, decimal, octal, binary, and ASCII. The default radix is hexadecimal; the default radix determines what value will be assigned to constants in the object file when a radix is not explicitly specified by a base descriptor.
Note:
The radix for numeric constants can be made different from the default radix specified with the directives radix or list r=. Also, allowable default radices are limited to hexadecimal, decimal, and octal.
Constants can be optionally preceded by a plus or minus sign. If unsigned, the value is assumed to be positive.
Note:
Intermediate values in constant expressions are treated as 32-bit unsigned integers. Whenever an attempt is made to place a constant in a field for which it is too large, a truncation warning will be issued.
The following table presents the various radix specifications:
Table: Radix Specifications - MPASM Assembler/MPLINK Linker
Note
Type
Syntax
Example
1
Binary
B’binary_digits’
B’00111001’
2
Octal
O’octal_digits’
O’777’
3
Decimal
D’digits’
.digits
D’100’
.100
4
Hexadecimal
H’hex_digits’
0xhex_digits
hex_digitsh
H’9f’
0x9f
9fh
5
ASCII
A’character’
’character’
A’C’
’C’
1.
A binary integer is �b’ or �B’ followed by one or more of the binary digits �01’ in single quotes.
2.
An octal integer is �o’ or �O’ followed by one or more of the octal digits �01234567’ in single quotes.
3.
A decimal integer is �d’ or �D’ followed by one or more decimal digits �0123456789’ in single quotes.
Or, a decimal integer is �.’ followed by one or more decimal digits �0123456789’.
4.
A hexadecimal integer is �h’ or �H’ followed by one or more hexadecimal digits �0123456789abcdefABCDEF’ in single quotes.
Or, a hexadecimal integer is �0x’ or �0X’ followed by one or more hexadecimal digits �0123456789abcdefABCDEF’.
Or, a hexadecimal integer is one or more hexadecimal digits �0123456789abcdefABCDEF’ followed by �h’ or �H’.
5.
An ASCII character is �a’ or �A’ followed by one character in single quotes. Or, an ASCII character is one character in single quotes.

Previous Next Microchip Support
Help Updated: 2014-11-14 16:47:35Z
Help Page: 42