binaryCalculatorPrototype/main.py

32 lines
652 B
Python
Raw Normal View History

2023-06-27 14:18:37 +03:00
import bitutilities as bu
import timeit
if __name__ == '__main__':
2023-06-27 14:18:37 +03:00
reg: bu.BasicRegister = bu.BasicRegister(bu.get_memory("memory"))
2023-06-27 14:18:37 +03:00
print()
print("Register 1:")
print(reg)
2023-06-27 14:18:37 +03:00
print()
reg2: bu.BasicRegister = bu.BasicRegister(bu.get_memory("more memory"))
2023-06-27 14:18:37 +03:00
print()
print("Register 2:")
print(reg2)
2023-06-27 15:53:20 +03:00
reg, reg2 = bu.align_registers(reg, reg2)
2023-06-27 14:18:37 +03:00
print()
2023-06-27 15:53:20 +03:00
sum_reg, carry = bu.binary_sum(reg, reg2, True)
2023-06-27 14:18:37 +03:00
print()
print("Sum & carry:")
2023-06-27 15:53:20 +03:00
print(sum_reg, carry)
print()
subtr_reg: bu.BasicRegister = bu.binary_subtraction_1_complement(reg, reg2)
print("Subtraction:")
print(subtr_reg)