# The .data assembler directive is used to specify information that will be stored in # the data segment of memory. This is used to initialize data values into memory. .data VALUE1: .word 1000 # Store the value 1000 in a word at label VALUE1 VALUE2: .word 1500 # Store the value 1500 in a word at label VALUE2 # The .text assembler directive is used to indicate instructions which are part of # the program and thus need to be stored in the text, or program, segment of memory. .text main: lw $2, VALUE1 # Load the data at memory location VALUE1 into register $2. lw $3, VALUE2 # Load the data at memory location VALUE2 into register $3. add $4, $2, $3 # Add value in register $2 to value in register $3 and # store in register $4. sub $5, $2, $3 # Subtract the value in register $3 from the value in # register $2 and store in register $5. slt $6, $5, $4 # Set value in register $6 to 1 if value in register $5 # is less than value in register $4, treating them as # signed numbers. Otherwise set value to 0. sltu $7, $5, $4 # Set value in register $7 to 1 if value in register $5 # is less than value in register $4, treating them as # unsigned numbers. Otherwise set value to 0. addi $10, $0, 8 # Store value ($0+8) in register $10 to be used as Offset. sw $4, VALUE1($10) # Store value in register $4 to memory location VALUE1($10) # which is VALUE1 + $10 = VALUE1 + 8. jr $31 # Return to calling code.