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.
MPASM Constant Forms | Radix | PIC Assembler Equivalent |
---|---|---|
B'binary_digits' | Binary | binary_digitsB |
O'octal_digits' | Octal | octal_digits[O|o|Q|q] |
D'decimal_digits' or
.decimal_digits | Decimal | decimal_digits[D|d| nothing] |
H'hexadecimal_digits' or
0xhexadecimal_digits | Hexadecimal | 0hexadecimal_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
.
movlw 10110011B ;binary value
movlw 72q ;octal value
movlw 34 ;decimal value
movlw 04Fh ;hexadecimal value
movlw 'b' ;ASCII value