MIPS Assembly Language: Exam 1, Exam 2 and Final Exam

Course Queries Competitions/Entrance Exams 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Competitions/Entrance Exams related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

# Prompt user to enter the integer scores for Exams 1, 2, and Final,
# read the scores,
# compute the weighted average score (using the following formula), and
# display a labeled output about the weighted average score.
# Formula: avg = (128/637)*e1Score + (307/1024)*e2Score + (feScore/2)
#   avgScore=128*(1/637)*e1Score+307*(1/1024)*e2Score+(1/2)*feScore
############################ data segment ################################
.data
scorePrompt0:       .asciiz "Enter integer score for Exam 1: "
scorePrompt1:       .asciiz "Enter integer score for Exam 2: "
scorePrompt2:       .asciiz "Enter integer score for Final Exam: "
avgMsg:         .asciiz "The weighted average is:  "
############################ code segment ################################
            .text
            .globl main
main:
            ################################################
            #   Get the scores, store in $t0, $t1, $t2
            ################################################

            li $v0, 4
            la $a0, scorePrompt0    # prompt for a score
            syscall
            li $v0, 5
            syscall         # read an integer
            move $t0, $v0

            li $v0, 4
            la $a0, scorePrompt1    # prompt for a score
            syscall
            li $v0, 5
            syscall         # read an integer
            move $t1, $v0

            li $v0, 4
            la $a0, scorePrompt2    # prompt for a score
            syscall
            li $v0, 5
            syscall         # read an integer
            move $t2, $v0


            ################################################
            #   Compute weighted average, store in $t4
            ################################################

            # multiply e1Score by 128
            sll $t0, $t0, 7

            # divide e2Score by 1024
            sra $t1, $t1, 10

            # divide feScore by 2
            sra $t2, $t2, 1

            # divide e1score by 637
            li $t5, 637         
            div $t0, $t5             
            mfhi $t0

            # multiply e2score by 307
            li $t5, 307         
            mul $t1, $t1, $t5

            li $t4, 0     # ensure $t4 is 0
            add $t4, $t4, $t0
            add $t4, $t4, $t1
            add $t4, $t4, $t2

            li $v0, 4
            la $a0, avgMsg
            syscall
            li $v0, 1
            move $a0, $t4
            syscall

            li $v0, 10      # graceful exit service
            syscall

The code above is an example but my question is how do i change this code to be (205/1024)*e1Score + #(256/854)*e2Score + (feScore/2) ? Prompt the user to enter the integer scores for Exam 1, Exam 2 and Final Exam, read the scores, compute the weighted average score (using the following formula), and display a labeled output about the weighted average score.

0 views
0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.