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

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

问题描述

我的程序询问用户他/她正在考虑的数字是否在列表中.用户输入y或n.如何检查用户是否在程序集中输入了 y 或 n?如果等于 121('y' 的十进制 ASCII 代码)或值等于 110('n' 的十进制 ASCII 代码,则将用户输入放入寄存器和分支是否足够?

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/实验室/secondyear/spim/node8.html

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

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

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