MIPS how can you compare a character taken from input?

Deadly 提交于 2019-12-12 19:04:26

问题


My program asks the user if the number he/she is thinking of is in a list. The user inputs a y or an n. How can I check if a user has entered y or n in assembly? Is it sufficient to put the user input into a register and branch if equal to 121 (decimal ASCII code for 'y') or branch if the value is equal to 110 (decimal ASCII code for 'n'?

Thanks in advance


回答1:


One can use the system call code for Read Character, which should be system call code 12, then the character (binary ASCII code) will be stored in $v0. Then you can make a register equal to 121 and another to 110. Then branch if equal.

SPIM system call codes: http://www.doc.ic.ac.uk/lab/secondyear/spim/node8.html



来源:https://stackoverflow.com/questions/1369735/mips-how-can-you-compare-a-character-taken-from-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!