Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I need to write a program with MIPS for an evaluation of an exam. If someone gets ≥ 40 points, he succeeded and if he gets <40 points, he failed.

At the beginning the variable "Success" get's 99, which means that we do not know if someone succeeded or not.

The task is to complete the program so that we get 1 for successful and 0 for not successful.



.data
Points : .word 42 # Exampoints
Success : .word 99 # 0 No, 1 Yes, 99 We don't know
Minimum: .word 40 # MinimumToSucceed 40 Points

.text
.globl main
.
.
.

What I have tried:

.data
Points : .word 42 # Exampoints
Success : .word 99 # 0 No, 1 Yes, 99 We don't know
Minimum: .word 40 # MinimumToSucceed 40 Points

.text
.globl main

main:

lw $2,Points
lw $3,Minimum
lw $4,Success

loop:blt $2,$3,end
li $4,1

end:li $4,0

li $2,10 #these two last lines are just to complete
syscall #the program without errors (not task related)

Oh i just discovered a problem: If i use numbers lower than 0 or greater than 99 for "Points", it still gives me 1 for sucessful (e.g 105 > 40) and 0 for failed (e.g. -5 < 40).

How can i integrate this in my program?
Posted
Updated 9-Jan-20 4:32am
v2
Comments
Kris Lantz 9-Jan-20 9:38am    
This smells like homework. Have you attempted the problem, so that one might offer some guidance, over just the solution?
Kornfeld Eliyahu Peter 9-Jan-20 9:50am    
Have you done ANYTHING on your own?
CP not much for a code-request site... It is more about help-yourself and CP will join in...
Patrice T 9-Jan-20 10:20am    
Use Improve question to update your question.
So that everyone can pay attention to this information.
Kris Lantz 9-Jan-20 10:28am    
You can check to make sure data is within the 0-99 bounds before checking the success/failed.
Member 14711617 9-Jan-20 10:43am    
Is it possible to write a text with assembler? I do not know how to say "Number too big or too low".

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900