我正在使用 MPLAB C18,它提供了一个内部汇编程序,可以从 C 项目调用汇编函数。我正在遵循有关如何使用内联汇编的规则,并且我怀疑有关“全文助记符必须用于表读/写”的某些内容在构建我的项目时会导致语法错误消息。
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])
这是我从PIC18F87J11数据表中获得的关于从闪存读取的代码。
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
这是我为了使汇编代码工作而进行的修改。我怀疑TBLRD*+ 的某些内容会导致语法错误。
_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
我希望有人能澄清'全文助记符必须用于表读/写'的含义以及可能导致构建错误的原因。
谢谢!