Microchip
直播中

李云

8年用户 169经验值
私信 关注
[问答]

PIC16汇编代码BRA k指令问题

根据我对数据表中的指令集的理解,这是一个相对的分支(PC)->;(PC)+1+k但是如果我使用BRA0x2it跳转到程序地址2,它似乎不会将其添加到当前PC值中。和GOTO一样。我可以做BRA标签,但是和GOTO标签一样,所以我看不出重点。非常感谢说明:-)BRW似乎工作正常,但我不想用我想跳过的行数加载W。

以上来自于百度翻译


      以下为原文

    From my understanding of the instruction set from the datasheet, this does a relative branch
(PC) --> (PC)+1+k
But if I use
BRA 0x2
it jumps to program address 2, it doesn't seem to add it to the current PC value.
Which to my mind makes it an absolute not relative jump. And the same as GOTO.
I can do BRA label, but that achieves the same as GOTO label, so I don't see the point.
Clarification would be greatly appreciated :-)
BRW seems to work okay, but I don't want to have to load W with the number of lines I want to jump.

回帖(19)

王焕树

2019-6-28 11:20:48
“BRA 0x2”告诉编译器您想要跳转到地址002,并且它为您计算出相对术语是什么。为了得到您期望的内容,将其编码为“BRA$+2”。

以上来自于百度翻译


      以下为原文

    "BRA 0x2" tell the compiler that you want to jump to address 002, and it works out what that is in relative terms for you.
To get what you are expecting, code it as "BRA $+2".
 
举报

王焕树

2019-6-28 11:40:37
换句话说,汇编程序所期望的参数是目的地址,而不是“k”。通常,您将把标签的名称放在那里,而不是一个常数。

以上来自于百度翻译


      以下为原文

    In other words, the argument the assembler is expecting is the destination address, NOT "k".
Normally you would put the name of a label there, not a constant.
 
 
举报

李维兴

2019-6-28 11:52:33
它是相对的,因为它只能向前或向后分支255条指令或256条指令。

以上来自于百度翻译


      以下为原文

    It is relative because it can only branch up to 255 instructions backward or 256 instructions forward.
 
举报

tijing忽忽

2019-6-28 12:09:17
在16F图片数据表的指令集摘要部分中:如果你真的阅读了那里的信息,你会发现数据表中惊人的内容……

以上来自于百度翻译


      以下为原文

    In the instruction set summary section of a 16F pic datasheet:

Amazing what you may find in the data sheets if you really read the information there......
举报

更多回帖

发帖
×
20
完善资料,
赚取积分