如果小于的话,哪个是分支的正确分支指令

发布于 2024-07-13 14:15:32 字数 448 浏览 7 评论 0原文

我昨天写了一个答案: 您见过或做过的最酷的黑客是什么? 我真的很努力地记住我的 6502 程序集,但我一辈子都不记得如何分支,如果小于...

  :1
  lda $C010
  cmp #$80
  bcc :1  ; branch if less than? I forget how to do that.
  lda $C000
  jsr $FDF0   ;output the accumulator value to the screen

有人知道指令是什么吗? BNE 和 BEQ 相等,BCC 用于进位,而 CMP 基本上是 SBC,会影响进位,但我不确定它在这种情况下是否有效。

I wrote an answer yesterday to this:
What's the coolest hack you've seen or done?
and I was trying really hard to remember my 6502 assembly, and I couldn't for the life of me remember how to branch if less than...

  :1
  lda $C010
  cmp #$80
  bcc :1  ; branch if less than? I forget how to do that.
  lda $C000
  jsr $FDF0   ;output the accumulator value to the screen

Anybody know what the instruction is?
BNE and BEQ are equals, BCC was for carry, and a CMP is basically an SBC and that affects the carry, but I'm not sure if it works in that case.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

罗罗贝儿 2024-07-20 14:15:32

BCC小于则为分支; 如果 BCS 大于或等于,则分支。 这里有一个很好的教程

然而,stu 的代码可以在没有 CMP 的情况下写得更简洁:

BIT $C010     ;clear the keyboard strobe
:1
LDA $C000     ;check for a keypress
BPL :1        ;taken if no keypress
JSR $FDFO     ;print the key

BCC is branch if less than; BCS is branch if greater than or equal. There's a nice tutorial here.

However stu's code can be written more concisely without CMP:

BIT $C010     ;clear the keyboard strobe
:1
LDA $C000     ;check for a keypress
BPL :1        ;taken if no keypress
JSR $FDFO     ;print the key
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文