I am trying to implement division and modulo in a strictly 8-bit microcomputer via an assembly like system. The task is to get the correct result out of two unsigned 8-bit numbers A and B (B > 0) for each of the two functions (or optionally both at the same time, in the best case). The calculations I can already do are:
- Add: x+y (optionally using carry bit)
- Sub: x-y
- Bitwise Nor (Invert if x == y)
- logical shift right (optionally shifting through carry)
- logical shift left (by adding)
- jump if a value is zero
- jump if a value is "negative" (but as is said, 10000000 would be a positive number in this case)
- jump if carry out is set
Every time I am trying to find a solution, I end up failing when trying to compare numbers, other than equal (would be: x-y === 0). Every solution I have found online, requires a subtraction and then checking the sign-bit (which I don't have here).
My last attempt was rewriting this answer, but ultimately failed at the greater or equal comparison for the reason mentioned above.
It would be great if someone got an idea of how to realize this, if it is even possible, or at least give a small hint. I thought about this for hours now... Please let me know if some information is missing.