I got my answer of imul How do you manually calculate imul -1 * 3? but now run into idiv.
For unsigned division, I simply use long division and can get the correct result.
50/4:
1100
________
100|00110010
100000
--------
10010
10000
--------
10
For signed division, -8/-4, 1111 1000 idiv 1111 1100, the program result is 0000 0010 (al, quotient).
How do I manually get 0010? What is the rule here?
1111 1000 / 1111 1100 doesn't work apparently. So I tried sign extending the dividend:
1 0000 0100
___________________
1111 1100|1111 1111 1111 1000
1111 1100
-------------------
11 1111 1000
11 1111 0000
------------
1000
this is also wrong...
An example is much appreciated, if 8 bits example is too tedious, 3 bit or 4 bit examples are ok. :)