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

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

# Name: Kumal Patel# Class ID: 139# Assignment Number: 2.data.word 0.word 0.word 0.asciiz "Kumal Patel" # 12.asciiz "Enter a number from 1 to 5: " # 24.asciiz "\n" # 53.asciiz "input is out of range" # 55.asciiz "Time = " #77.asciiz "Enter the first number: " # 85.asciiz "Enter the second number: " #110.asciiz "Even" # 136.asciiz "Odd" # 141.asciiz "Equal" # 145.asciiz "Less than" # 151.asciiz "Greater than" # 161.asciiz "Program complete" # 174.text.globl mainmain:# print namelui $t0, 0x1001addi $a0, $t0, 12addi $v0, $0, 4syscall# print new lineaddi $a0, $t0, 53addi $v0, $0, 4syscall # print new lineSTART:addi $a0, $t0, 53addi $v0, $0, 4syscall # prompt user to enter a number from 1 to 5addi $a0, $t0, 24addi $v0, $0, 4syscall # read integer from useraddi $v0, $0, 5syscall # store inputaddi $t1, $v0, 0# check if input is within bounds, if not print that it isntslti $t2, $t1, 6slt $t3, $1, $t1beq $t2, $0, IFbeq $t3, $0, IFj TOP
IF:addi $a0, $t0, 55addi $v0, $0, 4syscallj START# loop through $t1 timesTOP:addi $a0, $t0, 53addi $v0, $0, 4syscall # prints new lineaddi $t4, $t4, 1addi $a0, $t0, 77addi $v0, $0, 4syscall # prints "Time = "addi $v0, $0, 1addi $a0, $t4, 0

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture