Let’s use that simple branch instruction to do the following: Load the two words declared in the data statement shown to the right into registers, and then determine if either is ≥ 0. If either number is ≥ 0, print it out using syscall 1 (you do not have to include a leader of any sort). If a number is negative, do not print it out. End the program with a syscall 10. Note: you can declare words as either decimal or hexadecimal. SPIM understands both number systems. If only one number is printed out, which number is it?

Respuesta :

It prints first number.

Second number is negative and its value is: -1744764930

Explanation:

Required code is below.

========================================================================

.data

  data1:   .word   0x0001ead7

  data2:   .word   0x9800fffe

.text

main:   # load first number in to register $a0

  lw $a0, data1

  # if number is positive print it out

  bgez $a0, print

  # load second number in to register $a0

second:   lw $a0, data2

  # if number is positive print it out

  bgez $a0, print

  # end program

  li $v0, 10

  syscall    

print:   # print the given number

  li $v0, 1

  syscall

  # go back to main program

  j second