Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Do not use pseudo instructions such as la/li/move. you can use add/addi except li/la. for example lui $s0,0x1001 #load starting address 0x10010000 addi $v0,$0,4 #
Do not use pseudo instructions such as la/li/move.
you can use add/addi except li/la.
for example
lui $s0,0x1001 #load starting address 0x10010000 addi $v0,$0,4 # load command to print string addi $a0,$s0,0x0000 #address of ask syscall # print string
code below:
.data .asciiz "Enter an integer :" #0x10010000
.text .globl main
main: jal getsum ori $a0, $v0,0 ori $v0, $0, 1 syscall end: ori $v0,$0,10 syscall
In this assignment, you are to complete a MIPS program so it will perform the required tasks. The main function of the code is provided. You are to complete the program by writing two functions. Pay attention to the purpose of each function and how the parameters and return value are to be used. 1. isodd $a0 - integer value $vo - integer result This function must test the value is $a0. If the value in $a0 is odd, then the value of 1 should be assigned to $vo. If the value in $a0 is even, then the value of O should be assigned to $vo. (Hint: Use the and operation.) 2. getsum This function must prompt for and read integers until a zero is read. The function must test each integer to see if it is an odd number by calling isodd (above). The function should return the sum of the odd integers in $vo. All even numbers in the input should be ignored. Input can be either positive or negative. As this function must call another function, the $ra must be saved on the stack. General: Comment the beginning of your programs with your name and assignment number. Comment every instruction. Comment each function. Describe which registers are used in the function and how they are used. Submit your .asm file with the complete program. .data # add any strings at this point as needed .text .globl main main: jal getsum ori $a0, $v0,0 ori Svo, $0,1 syscall end: ori $v0, $0,10 syscall # call function to print sum of input # copy sum to $a0 # set output command # set command to stop program, # end program In this assignment, you are to complete a MIPS program so it will perform the required tasks. The main function of the code is provided. You are to complete the program by writing two functions. Pay attention to the purpose of each function and how the parameters and return value are to be used. 1. isodd $a0 - integer value $vo - integer result This function must test the value is $a0. If the value in $a0 is odd, then the value of 1 should be assigned to $vo. If the value in $a0 is even, then the value of O should be assigned to $vo. (Hint: Use the and operation.) 2. getsum This function must prompt for and read integers until a zero is read. The function must test each integer to see if it is an odd number by calling isodd (above). The function should return the sum of the odd integers in $vo. All even numbers in the input should be ignored. Input can be either positive or negative. As this function must call another function, the $ra must be saved on the stack. General: Comment the beginning of your programs with your name and assignment number. Comment every instruction. Comment each function. Describe which registers are used in the function and how they are used. Submit your .asm file with the complete program. .data # add any strings at this point as needed .text .globl main main: jal getsum ori $a0, $v0,0 ori Svo, $0,1 syscall end: ori $v0, $0,10 syscall # call function to print sum of input # copy sum to $a0 # set output command # set command to stop program, # end programStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started