MPASM to MPLAB XC8 PIC Assembler

v0.1

specific controller

MPASM XC8 Assembler
LIST P = DeviceName PROCESSOR DeviceName

LIST (indicates specific controller, e.g., LIST P=18F452) unique to PIC assembler.

Include Files

MPASM XC8 Assembler
INCLUDE <DeviceName.INC> #include <xc.inc>

Set device’s configuration bits

MPASM XC8 Assembler
__CONFIG The CONFIG directive with appropriate settings and values
  • MPASM:
__CONFIG  _WDT_OFF & _PWRTE_ON & _CP_OFF
  • PIC Assembler:
CONFIG WDT = OFF, PWRTE = ON, CP = OFF

Label name

Labels in PIC Assembler must be followed by a colon “:”
In MPASM the colon is optional.

Constants and Radices

By default, MPASM interprets the numeric constants as hexadecimal values.
PIC Assembler interprets them by default as decimal values!
This is where explicit definition can help with code portability.

MPASM XC8 Assembler
- RADIX DEC

numeric constants

Table 3-1. Equivalent Constants Radix Specifiers

MPASM Constant Forms Radix PIC Assembler Equivalent
B’binary_digits' Binary binary_digitsB
O’octal_digits' Octal octal_digits[O
D’decimal_digits’
or .decimal_digits
Decimal decimal_digits[D
H’hexadecimal_digits’ or
0xhexadecimal_digits
Hexadecimal 0hexadecimal_digits[H
A’character’ or ‘character’ ASCII ‘character’

MPASM

movlw b'10110011' ; binary value
movlw o'72' ;octal value
movlw d'34' ;decimal value
movlw 4F ;hexadecimal value
movlw ‘b’ ;ASCII value
  • decimal
movlw .34 ;decimal value

PIC Assembler

movlw 10110011B ;binary value
movlw 72q ;octal value
movlw 34 ;decimal value
movlw 04Fh ;hexadecimal value
movlw ‘b’ ;ASCII value

Ref