assign3.asm - Name Kumal Patel Class ID 139 Assignment...

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

# Name: Kumal Patel # Class ID: 139 # Assignment Number: 3 .data num1: .word 0 num2: .word 0 answer: .asciiz "The product is " positive: .asciiz "Enter a positive number " newline: .asciiz "\n" # add other strings at this point as needed .text .globl main main: jal getpos # get a positive number for the loop addi $s0, $v0, 0 # save input value repeat: beq $s0, $0, end # while there are more repeats lui $a0, 0x1001 # get address of first word addiu $a1, $a0, 4 # get address of second word jal getinput # call function to get input, store into addresses lui $t0, 0x1001 # get address of first word lw $a0, 0($t0) # get the first value from memory lw $a1, 4($t0) # get the second value from memory jal multiply # multiply the values, result in $v0 addi $a0, $v0, 0 # get value to print from $v0 lui $a1, 0x1001 # get start of data section addi $a1, $a1, 8 # get start of the product output string jal print # print results addi $s0, $s0, -1 # decrement counter j repeat # do it again print: addi $t0, $v0, 0 # store value of $v0 into temp register $t0 addi $a0, $a1, 0 # load address of register $a1, which is the address of the

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture