Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

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

Course Queries Competitions/Entrance Exams

Max. 2000 characters
Tuteehub
Replies

usr_profile.png

User

( 6 months 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.

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif