开发者

MIPS with Mars sim. - how to read a value from a keyboard input automatically (i.e. - no pressing enter to get the value)

Is there a specific sys开发者_开发知识库call or something I am missing in order to accomplish this?


You have to use syscall #12 to read a character. See the MARS syscall sheet for further details. Here goes an example that reads a character from console and prints the next ASCII code char

loop:  
  li   $v0, 12       
  syscall            # Read Character

  addiu $a0, $v0, 1  # $a0 gets the next char

  li   $v0, 11       
  syscall            # Write Character

  b loop
  nop
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜