I cant check if this is write as I have to do it at school. But I wanted to know if you can read over for me.
This is my multiplication
add $s2, $zero, $zero
add $t0, $zero, $zero
LOOP: beq $t0, $s0, EXIT
add $s2, $s1, $s2
addi $t0, $t0, 1
EXIT:
Okay it takes two integers stores them in $s0 and $s1
$s2 is a registry will be the product
$t0 is the increment
It suppose to loop until the values of $t0 = $s0
$s2 should equal the product of $s0 and $s1
add $t2, $s0, $zero
add $t0, $zero, $zero
LOOP: bne $t0, $s0, EXIT
beq $s1, $zero, DividebyZero
beq $s0, $zero, AnsZero
sub $t2, $t2, $s1
beq $t2, $zero, ANS
addi $t0, $t0, 1
j Loop
DividebyZero:
AnsZero:
ANS:
EXIT:
This one I am not sure what I am doing. I wrote the code in C++ first and came up with this.
#include <iostream>
using namespace std;
int main(){
int i = 0;
int num1, num2;
cout << "Enter Number 1" << endl;
cin >> num1;
cout << "Enter Number 2" << endl;
cin >> num2;
int x = num1;
while(i != num1)
{
if(num2 == 0){
cout << "Divsion by Zero" << endl;
return 0;
}
x -= num2;
if(x <= 0)
{
cout << num1 << " / " << num2 << " " << i << endl;
return 0;
}
i++;
}
if (num1 == 0){
cout << " 0 " << endl;
return 0;
}
}
$s0 and $s1 are still the numbers as they were before
$t0 is the increment number