当前位置:网站首页>MIPS汇编语言学习-02-逻辑判断-前台输入
MIPS汇编语言学习-02-逻辑判断-前台输入
2022-06-28 15:04:00 【阳光九叶草LXGZXJ】
一、前言
如何在电脑上运行MIPS汇编语言,这边不做赘述,请查阅之前的博客链接,里面有相关的安装包和运行方法:MIPS汇编语言学习-01-两数求和
二、源码
#实现功能:
#输入两个数,如果第一个数大于第二个数
#输出Sun,反之输出Moon
.data
#数据段
#设置两个字符串
DataSun: .ascii "Sun\0"
DataMoon: .ascii "Moon\0"
.text
#代码段
#$v0为5时,syscall可以读取一个Integer类型数据,
#并把值存放在$v0中。
#为了后续需要能够继续接受第二个数,
#我们用move方法把$v0的值移动到$t0中。
li $v0, 5
syscall
move $t0, $v0
li $v0, 5
syscall
move $t1, $v0
#MIPS汇编语言中没有if判断
#bgt函数表示大于,三个参数,
#如果第一个参数大于第二个参数,运行后面的行号sub0,sub0可以随意起名。
#如果第一个参数小于第二个参数,就继续往下执行。
bgt $t0, $t1, sub0
li $v0, 4
la $a0, DataMoon
syscall
#打印完结果,如果程序不退出,会继续执行后面行号sub0,所以我们加一个退出。
#当$v0是10的时候,调用syscall方法,程序退出。
li $v0, 10
syscall
sub0:
li $v0, 4
la $a0, DataSun
syscall
li $v0, 10
syscall
这次已经写了代码注释,就不单独拿出来一章讲解啦,其实是偷个小懒。
三、运行效果
(1)输入3和1时

(2)输入1和2时

边栏推荐
- R语言ggplot2可视化:使用patchwork包将两个ggplot2可视化结果纵向堆叠起来(stacking)形成组合图、一个可视化结果堆叠在另外一个可视化结果上
- Case driven: a detailed guide from getting started to mastering shell programming
- Maingene listed on the Hong Kong Stock Exchange: IPO with a market value of HK $4.3 billion was ignored by the market
- 3. Caller 服务调用 - dapr
- 技术弄潮儿
- The hidden crisis of Weilai: past, present and future
- 笔试面试算法经典–最长回文子串
- Tencent was underweight again by prosus, the major shareholder: the latter also cashed out $3.7 billion from JD
- The boss told me three times: low key, low key, low key
- 浪潮网络步步为赢
猜你喜欢
Oracle11g数据库使用expdp每周进行数据备份并上传到备份服务器

Jackie Chan and fast brand, who is the Savior of Kwai?

Facebook出手!自适应梯度打败人工调参

dolphinscheduler2. Installation of X (valid for personal test)

The boss told me three times: low key, low key, low key

坐拥1200亿,她又要IPO敲钟了

【黑马早报】腾讯回应大批用户QQ号被盗;薇娅丈夫公司被罚19万;中国恒大被申请清盘;关晓彤奶茶店回应被加盟商起诉...

美国乔布斯,殁了;中国乔布斯,卖了

第四大运营商,难成「鲶鱼」

After QQ was stolen, a large number of users "died"
随机推荐
从莫高窟到太平洋,海量数据找到了新家园
What is the renewal fee for PMP certificate?
Le patron a donné trois ordres: discret, discret, discret
【mysql学习笔记23】索引优化
[MySQL learning notes 23] index optimization
Leetcode (167) -- sum of two numbers II - input ordered array
Does Frankfurt currently support SQL?
R语言ggplot2可视化:patchwork包将一个ggplot2可视化结果和一个plot函数可视化结果横向组合起来形成最终结果图、两个可视化的组合结果对齐、并为组合图像的每个子图添加标题
Is PMP really useful?
Setsql function and risk of using lamdbaupdatewrapper
With 120billion yuan, she will ring the bell for IPO again
兼顾企业抗疫和发展的5个解决方案,来自IBM
With a return of 5000 times, the South African newspaper invested in Tencent to make a province
技术弄潮儿
老板囑咐了三遍:低調、低調、低調
动力电池,是这样被“瓜分”的
笔试面试算法经典–最长回文子串
Mingchuangyou products passed the listing hearing: seeking dual main listing with an annual revenue of 9.1 billion
Express模板引擎
The latest pycharm activation cracking code in 2022 is permanent_ Detailed installation tutorial (applicable to multiple versions)