I am using MPLAB C18 which provides an internal assembler to enable calling assembly functions from a C project. I am following the rules on how to use Inline Assembly and I suspect something about 'Full text mnemonics must be used for table reads/writes' is causing a syntax error message upon building my project.
The internal assembler differs from the MPASM assembler as follows:
No directive support
Comments must be C or C++ notation
Full text mnemonics must be used for table reads/writes. i.e.,
TBLRD
TBLRDPOSTDEC
TBLRDPOSTINC
TBLRDPREINC
TBLWT
TBLWTPOSTDEC
TBLWTPOSTINC
TBLWTPREINC
No defaults for instruction operands - all operands must be fully specified
Default radix is decimal
Literals are specified using C radix notation, not MPASM assembler notation. For example, a hex number should be specified as 0x1234, not H'1234'.
Label must include colon
Indexed addressing syntax (i.e., []) is not supported - must specify literal and access bit (e.g., specify as CLRF 2,0, not CLRF [2])
This is the code I am using which I got from the PIC18F87J11 datasheet about reading from flash memory.
MOVLW CODE_ADDR_UPPER ; Load TBLPTR with the base
MOVWF TBLPTRU ; address of the word
MOVLW CODE_ADDR_HIGH
MOVWF TBLPTRH
MOVLW CODE_ADDR_LOW
MOVWF TBLPTRL
READ_WORD
TBLRD*+ ; read into TABLAT and increment
MOVF TABLAT, W ; get data
MOVWF WORD_EVEN
TBLRD*+ ; read into TABLAT and increment
MOVF TABLAT, W ; get data
MOVWF WORD_ODD
This is the modification I made in order to get the assembly code working. I suspect something about the TBLRD*+ is causing a syntax error.
_asm
MOVLW CODE_ADDR_UPPER
MOVWF TBLPTRU
MOVLW CODE_ADDR_HIGH
MOVWF TBLPTRH
MOVLW CODE_ADDR_LOW
MOVWF TBLPTRL
READ_WORD:
TBLRD*+
MOVF TABLAT, W
MOVWF WORD_EVEN
TBLRD*+
MOVF TABLAT, W
MOVWF WORD_ODD
_endasm
I hope somebody can clarify what 'Full text mnemonics must be used for table reads/writes' means and what might be causing the build error.
Thanks!