I have an assignment that requires me to make a basic calculator that can do the four basic operations (add, subtract, multiply, divide) on integers in MIPS assembly. Part of the assignment requires user input validation to make sure an integer as well as a correct operand is input by the user. I have the basic calculator and operand input validation done. I am wondering what the best, or a good way to accomplish the integer input validation would be.
Currently, I am using the syscall for reading in an integer. When the user inputs anything other than an integer, a zero is stored in the $v0 register (the return register for a syscall function). At first I simply used a branch if equal to zero command to branch to a subroutine which asks the user to input a valid integer and jumps back to the subroutine that reads and stores the integer. The only problem with this is, the user cannot input 0, which is a valid integer.
What is a good way I could go about doing this? Should I read the input in as a string, instead of an integer, and then parse the string to make sure every char's ASCII value corresponds with an integer ASCII value? Please let me know if more information is required. I cannot post the code because this is a currently active assignment in my class.