CSCI206 - Computer Organization & Programming Two’s Complement Multiplication and Fibonacci Procedure Workshop zyBook: 8.3
Two’s complement multiplication When doing two’s complement multiplication, the signs will take care of themselves. The values (operands) must be fully “sign-extended” before operation (multiplication)! The result of two n-bits values will have 2*n bits. Thus sign extension must be 2*n bit long. We will discuss the topic in greater detail in Chapter 10
Examples Discussions and examples are from (2/23/2017) http://pages.cs.wisc.edu/~smoler/cs354/beyond354/int.mult.html A 4-bit, 2’s complement example: (-1) * (-7) == 7, extending to 8 bits 1111 1111 (-1) X) 1111 1001 (-7) ------------------------------------ 11111111 00000000 +) 11111111 ----------------------------------- 1111100000000111 ---> 7 Computer will extend the sign automatically to the full bits 1111100000000111 becomes 0000000000000111
Examples A 4-bit 2’s complement example 3*(-5) == -15, extending to 8 bits 0000 0011 (3) X) 1111 1011 (-5) ---------------------- 00000011 00000000 +) 00000011 0000001011110001 ---> -15 Computer will extend the sign automatically to the full bits 0000001011110001 becomes 1111111111110001 Run the program mult.s in MARS
Work in groups of three (or two) on the problem of Fibonacci procedure (Activity 15)