如何使用内联汇编与MPLAB C18? [英] How to use Inline Assembly with MPLAB C18?

查看:632
本文介绍了如何使用内联汇编与MPLAB C18?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的MPLAB C18提供了一个内部​​汇编,以便从C项目调用汇编函数。我下面就如何使用内联汇编的规则,我怀疑一些关于全文助记符必须用于表读/写在我的建设项目导致语法错误消息。

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])

这是code我使用这是我从 PIC18F87J11了关于从闪存中读取数据表

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

这是我为了得到大会code工作所做的修改。我怀疑一些关于 TBLRD * + 导致语法错误。

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.

谢谢!

推荐答案

我将不得不仔细检查,但我相信,你必须替换 TBLRD * + 通过助记符 TBLRDPOSTINC 。我稍后会发布一个编辑进行确认。

I will have to double check, but I believe that you have to replace TBLRD*+ with the mnemonic TBLRDPOSTINC. I'll post an edit later to confirm.

这篇关于如何使用内联汇编与MPLAB C18?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆