# MIPS Lab Assignment 2 # A program to print grade based on exam degree .data degree_message: .asciiz "Enter your exam degree (0-100): " grade_message: .asciiz "Your grade is: " A_grade: .asciiz "A\n" B_grade: .asciiz "B\n" C_grade: .asciiz "C\n" D_grade: .asciiz "D\n" F_grade: .asciiz "F\n" .text # Print prompt for user to input degree li $v0, 4 la $a0, degree_message syscall # Read user input for degree li $v0, 5 syscall move $t0, $v0 # save degree in $t0 # Determine grade based on degree li $t1, 90 # A grade threshold bge $t0, $t1, print_A # degree >= 90, print A grade li $t1, 80 # B grade threshold bge $t0, $t1, print_B # degree >= 80, print B grade li $t1, 70 # C grade threshold bge $t0, $t1, print_C # degree >= 70, print C grade li $t1, 60 # D grade threshold bge $t0, $t1, print_D # degree >= 60, print D grade # If none of the above conditions are met, print F grade li $v0, 4 la $a0, grade_message syscall la $a0, F_grade syscall j end print_A: li $v0, 4 la $a0, grade_message syscall la $a0, A_grade syscall j end print_B: li $v0, 4 la $a0, grade_message syscall la $a0, B_grade syscall j end print_C: li $v0, 4 la $a0, grade_message syscall la $a0, C_grade syscall j end print_D: li $v0, 4 la $a0, grade_message syscall la $a0, D_grade syscall j end # exit program end: li $v0, 10 syscall
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter