I'm attempting to calculate the span of 10 numbers, but I'm stuck before I can begin. I am able to load the set into memory using my LW commands, but after than NOTHING is working. When I do a dump after execution NOTHING works. The 10 values are there but that is it. How am I supposed to add, subtract, or execute any command for that matter? Nothing is being stored, period.
# This program computes and prints the span of a set of ten integers Set.
.data
Set: .word 9, 17, -7, 3, -27, 25, 42, 26, 8, -60
Span: .alloc 1
.text
lw $1, Set($0)
lw $2, Set($1)
lw $3, Set($2)
lw $4, Set($3)
lw $5, Set($4)
lw $6, Set($5)
lw $7, Set($6)
lw $8, Set($7)
lw $9, Set($8)
lw $10, Set($9)
add $11,$2,$3
sw $11, Span($0)
jr $31
My add command does nothing in this example, nor does the stor command. What am I doing wrong? Do I have to preallocated every single spot I want to use in memory? ($11) for example. I've tried numerous commands and none do anything beyond my final lw command.
Here's what I wrote in an attempt to create equivalent code to what you're trying to do:
You didn't really say exactly what was going wrong (program crashes? refuses to assemble?) so I'm not sure what advice to give, but your use of registers is suspicious -- especially $1 i.e. $at which my assembler won't even let me use without turning of the warning; this register is reserved for use by the assembler.