Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CS264 Computer Organization &Assembly; Programming Winter 2018 Quiz#5 The follow

ID: 3723659 • Letter: C

Question

CS264 Computer Organization &Assembly; Programming Winter 2018 Quiz#5 The following incomplete program (in the MIPS assembly language) reads an array of 100 records of employees from the keyboard, one at a time, and stores them in memory according to the ID of the employee, i.e. the employee with ID 5 will be stored in the 6h location. The ID is ranged from 0 to 99 and the records can be entered in any order, i.e. it is not necessary in the ascending order of their indexes (or indices). Each record consists of three data items: index: unique integer; full name: 19 upper and lower case letters; salary: int Complete the program by filling in the blanks. rd: space 2800 Prompti: asciiz "Enter the employee's ID" Prompt2: asciiz "Enter the employee's name Prompt3: ·asci iz “ Enter the employee's salary" text listo, 100 last 1,Record main: #StO used as a counter #Sti stores the starting ress of the array b$13, 20, hero, exit× read: la Promptl syscall li SvO syscall move St2, $v0 # to determine the address in the array-at which the ID will be stored. mul $t2, addu St2, Stl SvO, a Sao, Prompt2 li Sv0,4 syscall (20 lisa11 ey,Line× addiu $12, $12, move SaO, S12 li Sv0, 4X syscall la Sa0, Prompt3 li SvO, 4 syscall li$v0, 5 sw SvO, addi $t0 St0,-1 Sv0,10 syscall end:

Explanation / Answer

Screenshot:-

--------------------------------------------------------------------------------------------------------------------

Code:-

#variable declaration
        .data
Record: .space 2800
Prompt1: .asciiz "Enter the employee's ID "
Prompt2: .asciiz "Enter the employee's name "
Prompt3: .asciiz "Enter the employee's salary "
#program start
      .text
main:li $t0,100       #counter
      la $t1,Record    #array address load
      li $t3,28       #immediate to find location
read:beqz $t0,end    #loop to read each value
#user prompt for Employee ID
     la $a0,Prompt1
     li $v0,4
     syscall
     #read ID from user
     li $v0,5
     syscall
     #to generate appropriate address
     move $t2,$v0
     mul $t2,$t2,$t3
     addu $t2,$t1,$t2
     #store value in to address
     sw $v0,($t2)
     la $a0,Prompt2
     li $v0,4
     syscall
     #read and set length of the string
     li $a1,19
     addiu $t2,$t2,4
     move $a0,$t2
     li $v0,8
     syscall
     #Prompt user to get salary
     la $a0,Prompt3
     li $v0,4
     syscall
     #read salary
     li $v0,5
     syscall
     sw $v0,8($t2)
     #decrement counter
     addi $t0,$t0,-1
     #increment address
     addi $t1,$t1,4
    #end of the program
end:li $v0,10
    syscall