68000汇编语言 - CMPI.B [英] 68000 Assembly Language - CMPI.B

查看:623
本文介绍了68000汇编语言 - CMPI.B的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

What are the contents of the CCR and D3 after the following instructions sequence executes? Perform the calculation by hand and show your work.

MOVE.B    #7,D3
CMPI.B    #11,D3

我知道D3寄存器的内容将保持不变以我不确定如何做计算得到CCR标志。

I know the contents of the D3 register will remain unchanged by i am unsure of how to do the calculation to get the ccr flags.

能否有人为请告诉我的计算,你是如何做到的,并设置标志什么了,为什么。我真的很难理解这一点。

Could somone please show me the calculation how you did it and what flags are set off and why. I really have a hard time understanding this.

推荐答案

D3 将是不变 CMPI ,但当然它的低字节将 7 由于移动。 (感谢@unwind指出这一点。)

D3 will be unchanged by the CMPI, but of course its low byte will be 7 due to the MOVE. (Thanks to @unwind for pointing this out.)

该指令集的参考会告诉你, CMPI 的工作原理是减去第二次的第一个操作数。它还说, X 标记也不受影响,和其他人将根据结果设置如下:

The instruction set reference will tell you that CMPI works by subtracting the first operand from the second. It also says that the X flag is not affected, and the others are set according to the result as follows:


  • N 7-11< 0 ,所以 N = 1

  • 以Z :<!code> 7-11 = 0 ,所以 Z = 0

  • V 7-11 = -4 ,这是在范围符号数, V = 0

  • C 7-11 = -4 ,即出的无符号数的范围, C = 1

  • N: 7-11 < 0, so N=1
  • Z: 7-11 != 0, so Z=0
  • V: 7-11=-4, that's in range for signed numbers, V=0
  • C: 7-11=-4, that is out of range of unsigned numbers, C=1.

这是人类版本的标志,CPU实际使用按位逻辑:

These are the human versions for the flags, the cpu actually uses bitwise logic:


  • N :结果最显著位。在2的补再presenation,负数有MSB集。

  • 以Z :所有的结果位的只是按位 NAND Z = 1 如果所有位均为0。

  • V :这是一个棘手。 V =( - R7)*( - A7)* B7 + R7 * A7 *( - B7) R7 作为结果的MSB, A7 B7 两个操作数的最高位。这意味着你有一个符号溢出,如果从正减去一个负数给你负数,或者如果从消极减去一个正数给你正面的。

  • C :减法的最后的进,又名。在第9位。

  • N: The most significant bit of the result. In 2's complement represenation, negative numbers have the MSB set.
  • Z: Just a bitwise NAND of all the result bits. Z=1 if all bits are zero.
  • V: This one is tricky. V=(-R7)*(-A7)*B7+R7*A7*(-B7), with R7 being the MSB of the result, A7 and B7 the MSB of the two operands. What this means is that you have a signed overflow if subtracting a negative number from a positive gives you negative number, or if subtracting a positive number from a negative gives you positive.
  • C: the final carry of the subtraction, aka. the 9th bit.

这篇关于68000汇编语言 - CMPI.B的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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