I am trying to write a chip8 emulator in C#. It will be necessary to simulate in software the operations that take place in hardware on the real chip.
There is an opcode that requires detecting a whether a borrow occurred during the subtraction of two binary numbers.
Byte1 - Byte2
Does anyone have any ideas as to how I can use C# to tell if a borrow occurred or not?
You will need to compare each bit of the bytes… If the second byte bit is set but not the first, you have a borrow condition:
There may be a very clever boolean logic that gives you the answer, but I cannot come up with it now.