Jal print print result lui t0 0x1001 get address of

This preview shows page 1 - 3 out of 3 pages.

jal print# print resultlui $t0, 0x1001# get address of first wordlw $a0, 0($t0)# get the first value from memorylw $a1, 4($t0)# get the second value from memoryjal divide# multiply the values, result in $v0addi $a1, $v0, 0# get value to print from $v0lui $a0, 0x1001# get start of data sectionaddi $a0, $a0, 0x12# get start of product output stringori $a2, $0, 1# set flag to truejal print# print resultaddi $s0, $s0, -1# decrement counterj top# repeatend:ori $v0, $0, 10# set command to stop program,syscallgetpos: addi $sp, $sp, -4# decrease the stack to store $ra (stack grows from top to bottom)sw $ra, 0($sp)# save $ra on the stackask_again:lui $a0, 0x1001# set $a0 to start of addressaddi $a0, $a0, 46# get start of prompt
jal print# call to print the promptaddi $v0, $0, 5# syscall command to read an integersyscall# syscallslt $t1, $0, $v0# if 0 < $v0 set $t1 = 1bne $t1, $0, no_error# if $t1 is not 0 (meaning $v0 > 0), jump to noerroraddi $v0, $0, 4# set $v0 = 4, syscall command to print Error Messagelui $a0, 0x1001addi $a0, $a0, 74# get start of errormessagesyscall# print errormessagej ask_again# jump to askagain (repeat)no_error:lw $ra, 0($sp)

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture