汇编语言ccr学习汇编遇到麻烦
他提出了这些问题 一个。 13显然是样本集中最大的一条数据。将 13 存储到 D0 后,当另一个数字与它进行比较时,CCR 的状态是什么(只需给出 5 位并指示哪些位被触发)。 b.最后一块数据(0)移入 D1 寄存器后,CCR 的状态如何。
*
ORG $400
MOVEA.L #DATA,A0
CLR.B D0
NEXT MOVE.B (A0),D1
BEQ EXIT
CMP.B D0,D1
BLE EndTest
MOVE.B D1,D0
EndTest ADDA.L #1,A0
BRA NEXT
EXIT STOP #$2700
*
ORG $1000
Data DC.B 12,13,5,6,4,8,4,10,0
END $400
我编译了它,但在 easy68k 中没有看到 5 位。我知道 ccr 是由标志位组成的,但我不知道该怎么做。
He gave these questions
a. 13 is obviously the largest piece of data in the sample set. After 13 was stored in D0, what was the state of the CCR when another number was compared against it (just give the 5 bits and indicate which bits were triggered).
b. What was the state of the CCR after the final piece of data (0) was moved into the D1 register.
*
ORG $400
MOVEA.L #DATA,A0
CLR.B D0
NEXT MOVE.B (A0),D1
BEQ EXIT
CMP.B D0,D1
BLE EndTest
MOVE.B D1,D0
EndTest ADDA.L #1,A0
BRA NEXT
EXIT STOP #$2700
*
ORG $1000
Data DC.B 12,13,5,6,4,8,4,10,0
END $400
I compiled it, but I don't see 5 bits in easy68k. I know ccr is made of flag bits but i'm not sure what to do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此循环等效于以下 C 代码:
即循环将始终迭代所有值,并在找到末尾的零时终止。这意味着当您点击
EXIT
时,您已经完成了BEQ EXIT
检查,该检查测试了先前加载的结果并发现它为零。 CCR 将为 0x??04,即仅设置Z
、零标志,因为这是BEQ
检查的内容。就
BLE
测试而言,这是对标志的复杂检查;根据摩托罗拉68k参考手册表3.19,测试Z || (N && !V) || (!N && V)
,即N
/V
或零(即等于 部分),因此标志的几种组合可能会导致采用该分支。对于您的具体数据,我假设,鉴于先前的值为 12,您最终将设置N
,即 CCR 值为0x??08
(大多数 CPU 上的CMP
会执行减法并丢弃,并且 12-13 为负数)。关于 m68k 汇编,本 wikibook 是一个很好的介绍。它描述了条件分支/CCR 标志测试,但省略了上面的棘手部分......
This loop is equivalent to the following C code:
I.e. the loop will always iterate over all values and terminate when it finds the zero at the end. That means by the time you hit
EXIT
, you've gone through theBEQ EXIT
check that tested the result of the previous load and found it to be zero. The CCR will be 0x??04, i.e. only theZ
, zero flag set, as that's whatBEQ
checks for.As far as the
BLE
test goes, this is a complex check on the flags; According to Motorola's 68k reference manual, table 3.19, it tests forZ || (N && !V) || (!N && V)
, i.e. for mutual exclusivity ofN
/V
or zero (that'd be the equal part), so several combinations of the flags may result in that branch being taken. For your specific data, I would assume that, given the previous value was 12, you'll end up withN
set, i.e. a CCR value of0x??08
(CMP
on most CPUs does a subtract-with-discard, and 12-13 is negative).Regarding m68k assembly, this wikibook is a good intro. It describes conditional branches / CCR flag tests but leaves out the tricky bits above ...