![](/img/trans.png)
[英]Trouble Compiling my Microchip PIC18f4550 USB project using MPLAB X IDE C18 compiler. The compiler keep highlighting "syntax error" and won't compile
[英]How to use Inline Assembly with MPLAB C18?
我正在使用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
我希望有人可以弄清楚“ 对表读/写必须使用全文助记符 ”的含义以及可能导致构建错误的原因。
谢谢!
我将仔细检查,但我相信您必须将TBLRD*+
替换为助记符TBLRDPOSTINC
。 我稍后会发表修改以确认。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.