MIPS如何比较从输入中获取的字符? [英] MIPS how can you compare a character taken from input?

查看:1142
本文介绍了MIPS如何比较从输入中获取的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序询问用户他/她正在考虑的号码是否在列表中。用户输入y或n。如何检查用户是否在汇编中输入y或n?如果等于121(对于'y'的十进制ASCII码)或分支,如果值等于110(对于'n'

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'?

提前感谢

推荐答案

可以使用系统调用代码读取字符系统调用代码12,那么字符(二进制ASCII代码)将被存储在$ v0中,然后你可以使寄存器等于121,另一个寄存器等于110.然后分支如果相等。

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系统调用代码:
http://www.doc.ic.ac.uk/lab/secondyear/spim/node8.html

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

这篇关于MIPS如何比较从输入中获取的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆