已知机器字长8位,X=-61,Y=-79,试利用补码运算求X+Y的值,并判断是否发溢出
1个回答
展开全部
X = -61D = - 11 1101B
[X]原 = 1011 1101B
[X]反 = 1100 0010B
[X]补 = 1100 0011B
Y = -79D = -100 1111B
[Y]原 = 1100 1111B
[Y]反 = 1011 0000B
[Y]补 = 1011 0001B
求和:
[X]补 = 1100 0011B
[Y]补 = 1011 0001B (+
------------------------
[X+Y]补 = 10111 0100B
--
↑(Cs是符号位的进位,Cp是最高数值位的进位,⊕表示异或)
Cs⊕Cp = 1⊕0 = 1 ,负溢出
-[X+Y]反 =-0111 0011B
-[X+Y]原 =-1000 1100B
X+Y = -1000 1100B = -8CH = -140D
[X]原 = 1011 1101B
[X]反 = 1100 0010B
[X]补 = 1100 0011B
Y = -79D = -100 1111B
[Y]原 = 1100 1111B
[Y]反 = 1011 0000B
[Y]补 = 1011 0001B
求和:
[X]补 = 1100 0011B
[Y]补 = 1011 0001B (+
------------------------
[X+Y]补 = 10111 0100B
--
↑(Cs是符号位的进位,Cp是最高数值位的进位,⊕表示异或)
Cs⊕Cp = 1⊕0 = 1 ,负溢出
-[X+Y]反 =-0111 0011B
-[X+Y]原 =-1000 1100B
X+Y = -1000 1100B = -8CH = -140D
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询