I promise I will rate you! :) Write a complete program using MIPS assembly code
ID: 3647324 • Letter: I
Question
I promise I will rate you! :)Write a complete program using MIPS assembly code that prompts the user to enter two integers, passes both integers as arguments to a function that determines if the sum is even or odd, returns to the main which prints an appropriate message before exiting. Standard MIPS procedure calling conventions should be followed: passing arguments and returning function value, saving registers and return address before calling a function, and restoring saved registers and stack after function call.
Please, any help would be great.
Thanks for your time,
unoplinker
Explanation / Answer
globl main # the program starts here .data # begin declarations datamessage: # declare a string called message .asciiz "enter number: " .text # end declarations datamain: li $v0, 4 # declare a system call to print a string la $a0, message # put in $a0 the string to print syscall # end of the declaration of the system call # the string has been printed li $v0, 5 # declare a system call to read an integer syscall # end of the declaration of the system call # the integer is in $v0 #move $t0, $v0 # move in $t0 what in $v0 #li $v0, 1 # declare a system call to print an integer #move $a0, $t0 # move in $a0 what in $t0 #syscall # end of the declaration of the system call # the integer has been printed move $t1, $a0 li $v0, 4 # declare a system call to print a string la $a0, message # put in $a0 the string to print syscall # end of the declaration of the system call # the string has been printed li $v0, 5 # declare a system call to read an integer syscall # end of the declaration of the system call # the integer is in $v0 #move $t0, $v0 # move in $t0 what in $v0 #li $v0, 1 # declare a system call to print an integer #move $a0, $t0 # move in $a0 what in $t0 #syscall # end of the declaration of the system call # the integer has been printed move $t2, $a0 li $v0, 1 #declare a system call to print an integer add $t0, $t1, $t2 #set a0 to equal zero move $a0, $t0 syscall # end of the declaration of the system call # the integer has been printed li $v0, 10 #Exit syscall