Я пытаюсь реализовать этот java код на языке ассемблера MIPS, и я очень запутался. это то, что у меня есть до сих пор:
java код:
for (int c = 1; c <= rows; c++) {
number = highestValue; // reset number to the highest value from previous line
for (i = 0; i < c; i++) {
System.out.print(++number + " ");
}
highestValue = number; // setting the highest value in line
код сборки:
.text # tells the program where the code begins
move $t0, $zero # t0=0
move $t1, $zero # this will be similar to "int i = 0"
move $t2, $zero # this will be similar to "number = 0"
move $t3, $zero # this will be similar to "highestValue = 0"
add $t4, $zero, 1 # this is our c
move $t5, $a1 # this is what will have our user input thru command line (rows!)
# biggest for-loop for(int c = 1; c <= rows; c++)
for:
bgt $t4, $a1, exit
move $t2, $t3
for1: # for(i = 0; i < c; i++)
bgt $t1, $t4, exit1 # if c is greater than i
li $v0, 5
la $t2, printNum
syscall
add $t1, $t1, $1 # increment by 1
j for1
exit1:
move $t2, $t3
.data # tells to store under .data line (similar to declaring ints)
printNum: .ascii z "$t2"