Intel 8080:乘法溢出
Intel 8080: multiplication overflow
我有一个 8080 处理器的模拟器。我需要写一个程序,它可以通过移位和添加操作将两个两位数相乘(结果我可以期待四位数)
据我所知,intel-8080的所有数学运算都是在寄存器'A'中进行的,但它只能包含两位数。如果我使用多个 'ff' 和 'ff',我就会溢出。如何绕过这个问题? Google 说,对于我的任务,有进位标志,如果发生溢出,它将为“1”。
但是我不明白,我该如何使用它。
感谢关注
进位标志就像一个额外的位,即 MSB(最高有效位)。
Intel 8080/8085 Assembly Programming Manual.
As its name it implies, the carry flag is commonly used to indicate whether an addition causes a 'carry' into the next higher order digit. The carry flag is also used as a 'borrow' flag in subtractions.
这意味着,如果你有两个数字相加会使寄存器溢出:
FF + FF = 1111_1111
+ 1111_1111
= 1111_1110 + carry = 1
AE + 74 = 1010_1110
+ 0111_0100
= 0010_0010 + carry = 1
一旦设置,进位标志将保持设置状态,直到另一个加法 运行 不会导致进位。
A0 + 10 = 1010_0000
+ 0001_0000
= 1011_0000 + carry = 0
我有一个 8080 处理器的模拟器。我需要写一个程序,它可以通过移位和添加操作将两个两位数相乘(结果我可以期待四位数)
据我所知,intel-8080的所有数学运算都是在寄存器'A'中进行的,但它只能包含两位数。如果我使用多个 'ff' 和 'ff',我就会溢出。如何绕过这个问题? Google 说,对于我的任务,有进位标志,如果发生溢出,它将为“1”。
但是我不明白,我该如何使用它。
感谢关注
进位标志就像一个额外的位,即 MSB(最高有效位)。
Intel 8080/8085 Assembly Programming Manual.
As its name it implies, the carry flag is commonly used to indicate whether an addition causes a 'carry' into the next higher order digit. The carry flag is also used as a 'borrow' flag in subtractions.
这意味着,如果你有两个数字相加会使寄存器溢出:
FF + FF = 1111_1111
+ 1111_1111
= 1111_1110 + carry = 1
AE + 74 = 1010_1110
+ 0111_0100
= 0010_0010 + carry = 1
一旦设置,进位标志将保持设置状态,直到另一个加法 运行 不会导致进位。
A0 + 10 = 1010_0000
+ 0001_0000
= 1011_0000 + carry = 0