mips打印字符 [英] mips printing characters

查看:649
本文介绍了mips打印字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

li $a0, '0'
li $v0, 11
syscall

所以我有这段代码来打印$ a0中的内容

so I have this code to print what is in $a0

在打印出来的字符方面有什么区别 在-1和1之间?当我尝试打印-1而不是0时,火星只是抱怨该值.

In terms of characters being printed out what is the difference between -1 and 1? When I try to print -1 instead 0, mars just complains about the value.

是否存在任何数学函数来处理正数方面的负数?

Is there any mathematical function to handle negative numbers in terms of positive numbers?

推荐答案

Syscall 11打印一个字符.字符串"0"和"1"都由一个字符组成,而"-1"由两个字符(-"和"1")组成.

Syscall 11 prints one character. The strings "0" and "1" both consist of one character each, but "-1" consists of two characters ('-' and '1').

您可以将-1打印为两个单独的字符:

You could either print -1 as two individual characters:

li $a0, '-'
li $v0, 11    # print_character
syscall
li $a0, '1'
li $v0, 11    # print_character
syscall

或作为字符串:

 li $v0, 4    # print_string    
 la $a0, str     
 syscall          

 str:  .asciiz "-1"

或作为整数

 li $v0, 1    # print_int     
 li $a0, -1     
 syscall      

这篇关于mips打印字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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