68000 Assembly Language - CMPI.B

╄→尐↘猪︶ㄣ 提交于 2019-12-02 11:54:55

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.)

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, 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.

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

  • 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.
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!