I have MCU in Logisim and following asm code. It is working but I have to improve it - make it faster. How to do that? I understand that it depends on data input. My ideas - arrange input operands. For example 2*5=5+5 and the same 5*2=2+2+2+2+2 so I have to compate them first with each other and then arrange. How to do that? Any other ideas.
You can get my Logisim MCU: Download MCU.circ and instruction set Excel XLS file
Current instruction count: COMPARE = 4 STORE = 9 END = 10
Machine code: 3000 3101 2200 2300 1153 6509 0200 0130 5004 4202 500A
My asm code:
LDR R0, 0 //Read first number from the RAM
LDR R1, 1 //Read second number from the RAM
LDI R2, 0 //Sets result register to zero
LDI R3, 0 //Sets R3 (compare) register to zero
COMPARE:CMP R1, R3 //Checks if multiplication isn't already done
BREQ STORE //If previous compare numbers were identical, then jumt to STORE
ADD R2, R0 //If they werent 0, then add first number to result again
DEC R1 //Decrease second number or counter by 1
JMP COMPARE //Jump to compare
STORE: STR R2, 2 //Save result to 2. RAM adress
END: JMP END //END