3
.data memory_space: .word 4 #make space in memory for the name get_name: .asciiz "Enter student name\n" get_mark_1: .asciiz "Enter Assignment 1:\n" get_mark_2: .asciiz "Enter Assignment 2:\n" get_mark_3: .asciiz "Enter Assignment 3:\n" print_sum: .asciiz "Total: \n" print_average: .asciiz "\nAverage is: \n" print_name: .ascii "Name is: " .text main: #Start get name la $a0, get_name #load address and store it into register 0 li $v0, 4 #op code for print string syscall #prints the string located in $a0 la $a0, memory_space #sets $a0 to writing a word la $a1, memory_space #memory limit overflow protection li $v0, 8 #load op code for getting user input syscall #asks user to input a string la $a0, print_name #load address print_name li $v0, 4 #op code for print string syscall #prints the string located in $a0 la $a0, memory_space #load address

Computer Infrastructure Assignment

Embed Size (px)

DESCRIPTION

Computer Infrastructure Assignment

Citation preview

.datamemory_space: .word 4 #make space in memory for the name get_name: .asciiz "Enter student name\n" get_mark_1: .asciiz "Enter Assignment 1:\n" get_mark_2: .asciiz "Enter Assignment 2:\n" get_mark_3: .asciiz "Enter Assignment 3:\n"

print_sum: .asciiz "Total: \n" print_average: .asciiz "\nAverage is: \n" print_name: .ascii "Name is: "

.text main: #Start get name la $a0, get_name #load address and store it into register 0 li $v0, 4 #op code for print string syscall #prints the string located in $a0

la $a0, memory_space #sets $a0 to writing a word la $a1, memory_space #memory limit overflow protection li $v0, 8 #load op code for getting user input syscall #asks user to input a string

la $a0, print_name #load address print_name li $v0, 4 #op code for print string syscall #prints the string located in $a0

la $a0, memory_space #load address li $v0, 4 #op code for print string syscall #prints the string located in $a0 #End get name #Start get marks 1 la $a0, get_mark_1 #load address and store it into register 0 li $v0, 4 #op code for print string syscall #prints the string located in $a0 li $v0, 5 syscall move $s0, $v0 #move the number to read into $s0 #End get marks 1 #Start get marks 2 la $a0, get_mark_2 #load address and store it into register 0 li $v0, 4 #op code for print string syscall #prints the string located in $a0

li $v0, 5 syscall move $s1, $v0 #move the number to read into $s1 #End get marks 2 #Start get marks 3 la $a0, get_mark_3 #load address and store it to register 0 li $v0, 4 # code for print string syscall #prints the string located in $a0

li $v0, 5 syscall move $s2, $v0 #move the number to read into $s2

#End get marks #Print sum la $a0, print_sum #load address print_output li $v0, 4 #op code for print string syscall #prints the string located in $a0 #Compute sum add $s3, $s0, $s1 add $s3, $s3, $s2 #print sum add $a0, $zero, $zero add $a0, $s3, $zero li $v0, 1 syscall # End print sum #Print the average la $a0, print_average #load address print_output li $v0, 4 #op code for print string syscall #prints the string located in $a0 #Compute average addi $s4, $zero, 3 div $s3, $s4 mflo $s5 mfhi $s6 #storing value o #print out average add $a0, $zero, $zero add $a0, $s5, $zero li $v0, 1 syscall # End print average #Exit the program li $v0, 10 syscall #exit program