Hello all,

i need your help regaring this code, which is in python and i need to convert it into mips??

register $s0 holds the base address of list my_data, $s1 holds the length of the list my_data,
register $s2 holds the base address of list my_data2 and $s3 holds the length of the list
def sum_to_x(x):
sum = 0
for i in range (x):
sum += i
return sum
my_data = [1, 3, 6, 7]
my_data2 = [2, 1, 5]
for i in range( len( my_data ) ):
my_data[ i ] = sum_to_x( my_data[ i ] )
for i in range( len( my_data2 ) ):
my_data2[ i ] = sum_to_x( my_data2[ i ] )

thanks in advance!!!

Edited by i dont know

8 Months
Discussion Span
Last Post by rproffitt

and yeah btw here is what i have done on this code:

    my_data: .word 1, 3, 6, 7
        my_data2: .word 2, 1, 5
    la $s0, my_data    # based address of list A loaded into $s0
addi $s1, $zero, 4  # $s1 is set to the size of the my_data
    la $s2, my_data2      # based address of list B loaded into $s2
        addi $s3, $zero, 3  # $s3 is set to the size of the my_data2`

Can you reveal why that's not helpful? You didn't call out this is some homework or such. I deal with embedded computers all the time and we are always cross compiling. While I did write a lot of assembler code, for many reasons we move to cross compilers to make the systems maintainable.


Read https://www.daniweb.com/programming/threads/435023/read-this-before-posting-a-question next. The problem is that this is your homework and what is covered in this class and prerequisites lead up to this assignment. As in that link, it's rare to find folk do your homework.

As it stands maybe a loop and adding up the values is next but there is no clear link to your homework assignment or what we call the requirements. Maybe coding in python wasn't a good start if you were going to try to write in assembler.

Think of the python code as your translation from the requirements. Something possibly lost in translation.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.