MIPS与Mars按enter键后如何读取值?

MIPS与Mars按enter键后如何读取值?,mips,mars-simulator,Mips,Mars Simulator,我如何读取值以便在之后将其存储在内存中?我需要让用户输入值,然后按enter键,这样我就可以获得这些值并使用它们 谢谢您应该使用服务5读取整数,6读取浮点,7读取双精度,服务8读取字符串。有关提供的系统调用服务,请参见MARS 下面是一个从控制台读取整数和字符串并将结果保存在变量number和buffer中的示例: .data number: .word 0 buffer: .space 80 .text li $v0, 5 # service 5 reads integer

我如何读取值以便在之后将其存储在内存中?我需要让用户输入值,然后按enter键,这样我就可以获得这些值并使用它们


谢谢

您应该使用服务5读取整数,6读取浮点,7读取双精度,服务8读取字符串。有关提供的系统调用服务,请参见MARS

下面是一个从控制台读取整数和字符串并将结果保存在变量
number
buffer
中的示例:

.data
  number: .word 0
  buffer: .space 80

 .text
   li $v0, 5 # service 5 reads integer from console
   syscall

   sw $v0, number # Store read integer into number
   li $v0, 8 # service 8 reads a string
   la $a0, buffer
   li $a1, 80  # buffer size
   syscall  # input text will be stored in buffer 

   li $v0, 7  # service 7 reads double
   syscall # $f0-$f1 contains the double read
   mov.d $f2, $f0
   syscall # read another double

   div.d $f12, $f2, $f0  # Divide the first double by the second double
   li $v0, 3
   syscall  # Print result of division

你能告诉我如何在系统调用中使用7来获得一个双精度值,然后在它们之间进行一些分割吗?这是非常棒的帮助,现在请告诉我如果$f12小于$f8,如何进行比较,然后转到标签示例。。。我尝试使用c.lt.d$f12,$f8 bc1tEXAMPLE@Andr阿尔瓦雷斯:没错。如果
$f12
小于
$f8
,则必须比较发出
c.lt.d$f12,$f8
设置协处理器1标志0为真的
。。。我如何向您发送代码以便您可以查看?这是一个计算体重的程序,然后除以一个人的身高x再除以身高,如果低于20,那么这个人是瘦的,如果在20-25之间,那么这个人的正常体重和高于25的体重是胖的。。。我已经做了所有这些,除了最后一部分的条件句。。。