3.1 Constants and Radices

The default radix for constants in the PIC Assembler is different to that used by MPASM and the radix specifiers used by each assembler are different.

Without any radix specifier or directive, numeric constants in the PIC Assembler are interpreted as decimal values. Such values would be interpreted as hexadecimal in MPASM. Use the RADIX hex directive in migrated assembly code to ensure that the default radix assumed by the PIC Assembler matches that used by MPASM.

The MPASM radix specifiers and the equivalent specifiers used by the PIC Assembler are tabulated below.

Table 3-1. Equivalent Constants Radix Specifiers
MPASM Constant FormsRadixPIC Assembler Equivalent
B'binary_digits'Binarybinary_digitsB
O'octal_digits'Octaloctal_digits[O|o|Q|q]
D'decimal_digits' or .decimal_digitsDecimaldecimal_digits[D|d|nothing]
H'hexadecimal_digits' or 0xhexadecimal_digitsHexadecimal0hexadecimal_digits[H|h] or 0xhexadecimal_digits
A'character' or 'character'ASCII'character'

Note that the binary digits suffix (B) used by the PIC Assembler must be in upper case. Hexadecimal values must always begin with a zero digit, 0.

The following example shows the PIC Assembler's radix specifiers in use.
movlw 10110011B  ;binary value
movlw 72q        ;octal value
movlw 34         ;decimal value
movlw 04Fh       ;hexadecimal value
movlw 'b'        ;ASCII value