完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
根据我对数据表中的指令集的理解,这是一个相对的分支(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个回答
|
|
|
“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". |
|
|
|
|
|
换句话说,汇编程序所期望的参数是目的地址,而不是“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. |
|
|
|
|
|
它是相对的,因为它只能向前或向后分支255条指令或256条指令。
以上来自于百度翻译 以下为原文 It is relative because it can only branch up to 255 instructions backward or 256 instructions forward. |
|
|
|
|
|
在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...... |
|
|
|
|
|
如果你真的读了那里的信息,你会发现数据表里有令人惊奇的东西……但是阅读材料就像,太难了!
以上来自于百度翻译 以下为原文 Amazing what you may find in the data sheets if you really read the information there...... But that reading stuff is like, so hard! |
|
|
|
|
|
上面的答案不错,但我将解决BRA和GOTO之间的一个重要区别。GOTO使用PCLATH提供目的地址的HO位。对于GOTO来说,这是页码。BRA不使用PCLATH。所以不管PCLATH中包含什么,BRA都可以安全地使用——只要目标在范围之内,并且汇编器会检查它。这对于操纵PCLATH的多(代码)页程序来说很重要。我发现BRA在中断代码中特别有用,因为输入PCLATH是未知的,而设置PCLATH是浪费的周期。只要范围足够,我就使用BRA。它避免了惊奇。格伦培迪:第1行:低于-gt;忘记了线程头显示的方式。:
以上来自于百度翻译 以下为原文 The answers above are good, but I'll address an important difference between BRA and GOTO. GOTO uses PCLATH to supply the HO bits of the destination address. For GOTO, that's the page number. BRA does NOT use PCLATH. So BRA can safely be used no matter what is contained in PCLATH - as long as the destination is within range and the assembler will check that. This difference is important with multi (code) page programs that manipulate PCLATH. I find BRA particularly useful in interrupt code where the incoming PCLATH is unknown and setting PCLATH is otherwise a wasted cycle. I use BRA whenever the range is sufficient. It avoids surprises. GlennP Edit: Line 1: below -> above. Forgot how the threaded headers display. :-( |
|
|
|
|
|
|
|
|
|
|
|
还有一个重要的区别。然而,嵌入在OP代码中的数字会影响PC,如果您使用的话,结果将是:
以上来自于百度翻译 以下为原文 There's also an important difference. The number embedded in the op-code influences PC as (PC) <-- (PC)+1+k However, if you use bra $+k the result will be: (PC) <-- (PC)+k |
|
|
|
|
|
…它指向数据表中的一个勘误表/错字:语法:[标签]文胸$+kPopand:-256 & lt;=k& lt;=255-它应该是如我在POST后4中所陈述的;即-255和lt;=k& lt;=256。&编辑;gt;因为字面“K”被指定为有符号的9位值,所以应该对句法进行校正:语法:[标签]文胸$ +(k+ 1)操作数:- 256和lt=k& lt;=255
以上来自于百度翻译 以下为原文 ... which points to an errata/typo in the datasheets: Syntax: [ label ] BRA $+k Operand: -256 <= k <= 255 It should be as I've stated in Post #4; Syntax: [ label ] BRA $+(k+1) Operand: -256 <= k <= 255 |
|
|
|
|
|
因为当计算“$”参数时,PC已经增加了,这不意味着数据表:中显示的语法是正确的吗?在数据表中声明如下:
以上来自于百度翻译 以下为原文 Since the PC will have already been incremented when the '$' argument is evaluated doesn't that imply that the syntax shown in the datasheet: [ label ] BRA $+k is correct? This is stated in the datasheet as: |
|
|
|
|
|
不,下面将产生一个“超出范围”的装配错误:而这将成功构建。
以上来自于百度翻译 以下为原文 No, the following will generate an "out of range" assembly error: bra $ - .256 whereas this bra $ + (-.256+1) will build succeeded. |
|
|
|
|
|
不,以下将产生一个“超出范围”的组装错误:而此构建将成功。好的,这个分支到哪里?胸罩说明书本身还是文胸前的说明书?
以上来自于百度翻译 以下为原文 No, the following will generate an "out of range" assembly error: bra $ - .256 whereas this bra $ + (-.256+1) will build succeeded. OK, where does this branch to? bra $-1 ; To the bra instruction itself or to the instruction before the bra ? |
|
|
|
|
|
|
|
|
|
|
|
在胸罩说明书之前立即传到说明书。分支到自身,使用
以上来自于百度翻译 以下为原文 That branches to the instruction immediately before this BRA instruction. To branch to itself, use bra $ |
|
|
|
|
|
在胸罩说明书之前立即传到说明书。分支到自身,使用是的,这就是我所看到的结果。因此,在将$参数增加到BRA指令之后的指令之前对其进行评估,这似乎与数据表中所说的相反:因为在$指向bra指令并且k=0的情况下(根据您的语法),PC($)应该设置为tOPC+1+0($+1),下一个指令是什么?所以它不能像你所说的那样,但事实上如数据表所示。还是我完全糊涂了!(当然是可能的)。
以上来自于百度翻译 以下为原文 That branches to the instruction immediately before this BRA instruction. To branch to itself, use bra $ Yes that is what I see as a result. So the $ argument is evaluated BEFORE being incremented to the instruction AFTER the BRA instruction, this seems to be in contrast to what it says in the data sheet: since in the case of bra $ if the $ points to the bra instruction and the k = 0 then (according to your syntax ) the PC ($) should be set to PC +1 +0 ($+1) which is the next instruction? So it must NOT be BRA $+(k+1) as you have but actually BRA $+k as shown in the data sheet? Or am I totally confused! (certainly possible). |
|
|
|
|
|
你让我头疼。我也感到困惑,但我认为这是文件的措辞。BRB…得喂饱我的脑子。:)
以上来自于百度翻译 以下为原文 You are making my head hurts. ;) I am getting confused here too, but I think it is the documentation wording. Brb... have to feed my brain. :) |
|
|
|
|
|
是的,我同意和抱歉头痛!我认为当数据表说PC可能已经增加,但$参数似乎在增加之前被评估,否则简单的$参数将跳转到下一条指令时,数据表是不正确的(或者至少是误导性的)。这个语句看起来是不正确的。BRA指令后面跟着一个字面常数(例如,BRA 0x00)似乎产生一个分支,该分支指向一个位置,该位置是当前CODE块的起始地址+字面值(如果它在BRA指令的范围内)。编辑:我相信这是汇编程序的一个功能,不是硬件。顺便说一句,我从来不使用这种语法($+),我总是对所有BRA和GOTO目的地使用标签,防止我的大脑受到如此大的伤害!
以上来自于百度翻译 以下为原文 Yes, I agree and sorry about the headache! I think the data sheet is incorrect (or at least misleading) when it says The PC may have been incremented but the $ argument appears to be evaluated BEFORE the increment, otherwise the simple $ argument would jump forward to the next instruction. This statement appears to be incorrect. The BRA instruction followed by a literal constant (BRA 0x00 for example) appears to produce a branch to a location that is the starting address of the current CODE block + the literal (if that is within the range of the BRA instruction). EDIT: This is a function of the assembler I believe, not the hardware. Incidentally I never use this syntax ($+), I always use labels for ALL BRA and GOTO destinations, keeps my brain from hurting so much! |
|
|
|
|
|
记住,“$”是一个汇编概念。PC是一个硬件概念。所以汇编器使用$作为当前指令的地址。H/W在加上“K”GP之前递增PC。
以上来自于百度翻译 以下为原文 Remember, the '$' is an assembler concept. PC is a hardware concept. So the assembler uses $ as the address of the current instruction. The H/W increments PC before the signed addition of 'k'. GP |
|
|
|
|
|
当然,是的。我认为在相同的指令描述中使用这两个“术语”的数据表会让人困惑。
以上来自于百度翻译 以下为原文 Absolutely, yes. I think the datasheets using both of these "terms" in the same instruction description makes it confusing. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
483 浏览 0 评论
5804 浏览 9 评论
2344 浏览 8 评论
2233 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3538 浏览 3 评论
1143浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1114浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
882浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
485浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-8 09:33 , Processed in 1.417378 second(s), Total 110, Slave 93 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1961