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
my_data2.
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!!!

That's what we use Cross Compilers for. I don't know of many that will hand code from what you supplied but I did see students try that. But in a commercial setting the Cross Compilers are called on.

And yes, there are such for your project. Read from https://www.google.com/search?q=python+compiler+for+mips

commented: Rep here because I somehow couldn't give you rep elsewhere. +8

actually this is was not helpful at all, thanks for ur replying anyway

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

.data
    my_data: .word 1, 3, 6, 7
        my_data2: .word 2, 1, 5
.text
    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.

actually yeah this is my homework and i need ur help please!!

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.