diff --git a/src/multiply.py b/src/multiply.py index 198251d..124c1ad 100644 --- a/src/multiply.py +++ b/src/multiply.py @@ -11,35 +11,12 @@ al = align_binary_to_right def multiply(x, y, method): if method == 4: n = len(bin(x)[2:]) # base registry bit length, usually written as n + # every table line has registers like so: RG1, RG3, RG2 data_table = [[["0"*(2*n+1), "0" + bin(y)[2:] + "0"*n, bin(x)[2:], "-"]]*2] - print(f"Starting with: {data_table}") - print(data_table[-1][-1][2]) - print(int('0b' + data_table[-1][-1][2], 2)) + while int('0b' + data_table[-1][-1][2], 2) != 0: data_table.append([]) - ''' - if data_table[-2][-1][2][0] == "1": - data_table[-1].append([ - al(bin(int("0b"+data_table[-2][-1][0], 2) + int("0b"+data_table[-2][-1][1], 2))[-(2*n+1):], 2*n+1), # RG1 + RG3 - data_table[-2][-1][1], - data_table[-2][-1][2], - ]) - - data_table[-1].append([ - data_table[-1][-1][0], - '0' + data_table[-1][-1][1][:-1], # 0.r(RG3) - data_table[-2][-1][2][1:] + '0', # l(RG2).0 - ]) - ''' - - ''' - if data_table[-2][-1][2][0] == "1": - data_table[-1].append([ - al(bin(int("0b"+data_table[-2][-1][0], 2) + int("0b"+data_table[-2][-1][1], 2))[-(2*n+1):], 2*n+1), # RG1 + RG3 - '0' + data_table[-2][1][:-1], - data_table[-2][2][1:] + '0', # l(RG2).0 - ''' if data_table[-2][-1][2][0] == "1": data_table[-1].append([ @@ -64,9 +41,6 @@ def multiply(x, y, method): "0.r(RG3), l(RG2).0" ]) - - print(data_table) - return data_table if __name__ == "__main__": @@ -78,7 +52,7 @@ if __name__ == "__main__": from lib.prettytable import PrettyTable pt = PrettyTable() pt.field_names = ["RG1", "RG3", "RG2", "Operations"] - + for i in dt[1:]: for j in range(len(i)): if j+1 == len(i):