2
$\begingroup$

While reading Computer Architechture book by M.Mano. I came across Arithmetics Microoperations sections which has two microoperations which confuses me a lot,

R3 <- R1 - R2 ( Minus Microoperation )

R3 <- R1 + complemented(R2) + 1 ( Subtract Microoperation ).

Can someone tell me the difference?

$\endgroup$
2
$\begingroup$

Suppose we're working with unsigned bytes, e.g. modulo 256.

Let's say R1 = 100 and R2 = 70. Direct subtraction should give us 100 - 70 = 30:

01100100
01000110 -
========
00011110

Modulo 256, subtracting 70 is the same as adding 256 - 70 = 186, because -70 is +186. The complement of 70 is 255 - 70 = 185, which is just one less. Therefore, the following sum produces 100 + 185 + 1 = 286 which is the same as 30 (modulo 256). Of course, the ninth bit 'falls off' when doing 8-bit arithmetic, so we get 30 as a result.

 01100100
 10111001
 00000001 +
 ========
100011110

So both methods give the same result, just in a different way.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.