I have a 8080 processor's emulator. I need write a program, which can multiple two two-digit numbers with operations of shifting and adding(as a result I can expect four-digit number)
As I know, all mathematic operations in intel-8080 are made in register 'A', but it can contain only two-digit numbers. If I multiple 'ff' and 'ff', I get an overflow. How to bypass this problem? Google said, that for my task there is carry flag, which will be '1', if overflow happens.
But I cannot understand, how I can use it.
Thanks for attention.
The carry flag is like an extra bit that is the MSB (Most significant bit).
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.
What this means, is that if you have an addition of two numbers that will overflow the register:
FF + FF = 1111_1111
+ 1111_1111
= 1111_1110 + carry = 1
AE + 74 = 1010_1110
+ 0111_0100
= 0010_0010 + carry = 1
Once set, the carry flag will remain set until another addition is run that does not cause a carry.
A0 + 10 = 1010_0000
+ 0001_0000
= 1011_0000 + carry = 0