Booth's Algorithm - C Implementation
#include <stdio.h> #define WORD 4 #define VERBOSE 1 //0 /* * 02 DEC 2011 (CSC2304) * Implementation of the Booth's Algorithm. */ void twosComplementAddition(char[], char[]); void rightShift(char[], char); void addition(char[], char[]); char* twosComplementMultiplication(char M[], char Q[]) { char C; char *A = (char*) malloc(sizeof(char)*(2 * WORD + 1)); char processedQ[WORD+ 1]; char Q0, Q_1 = '0'; int i, j; strcpy(A, "0000"); if (VERBOSE) { printf("\n A | Q | M |"); printf("\n %s | %s | %s | Initial", A, Q, M); printf("\n-------------------------------------------------------------"); } for (i = 0, j = 1; i < WORD; i++, j++) { Q0 = Q[WORD - 1]; if (VERBOSE) { printf("\n %s | %s | %s | Cycle %d", A, Q, M, j); } if (Q0 == '0' && Q_1 == '1')...