当前位置:网站首页>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时

边栏推荐
- Send2vec tutorial
- Leetcode(665)——非递减数列
- 一文教你快速生成MySQL数据库关系图
- 坐拥1200亿,她又要IPO敲钟了
- The boss told me three times: low key, low key, low key
- WSUS客户端访问服务端异常报错-0x8024401f「建议收藏」
- 3. caller service call - dapr
- Maingene listed on the Hong Kong Stock Exchange: IPO with a market value of HK $4.3 billion was ignored by the market
- Recommended practice sharing of Zhilian recruitment based on Nebula graph
- Introduction to common components of IOT low code platform
猜你喜欢

Q-Tester 3.2:适用于开发、生产和售后的诊断测试软件

新零售线下店逆势起飞,通膨乌云下的消费热情

Angers medical sprint scientific innovation board: annual revenue of RMB 300million and proposed fund raising of RMB 770million

蔚来潜藏的危机:过去、现在到未来

The latest pycharm activation cracking code in 2022 is permanent_ Detailed installation tutorial (applicable to multiple versions)

Le patron a donné trois ordres: discret, discret, discret

dolphinscheduler2.X的安装(亲测有效)
一文教你快速生成MySQL数据库关系图

快手投资电商服务商易心优选

WPF 视频硬解码渲染播放(无空域)(支持4K、8K、高帧率视频)
随机推荐
快手投资电商服务商易心优选
R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和数据表格横向组合起来形成最终结果图
Leetcode(665)——非递减数列
[spatial & single cellomics] phase 1: Study on PDAC tumor microenvironment by single cell binding spatial transcriptome
Vscode writes markdown file and generates pdf
Classmate Zhang hasn't learned to be an anchor yet
Successful cases of rights protection of open source projects: successful rights protection of SPuG open source operation and maintenance platform
不要使用短路逻辑编写 stl sorter 多条件比较
【mysql学习笔记24】索引设计原则
Conversion between pointcloud and numpy arrays in open3d
How can I get the stock account opening discount link? Is it safe to open a mobile account?
Power battery is divided up like this
Rails进阶——框架理论认知与构建方案建设(一)
笔试面试算法经典–最长回文子串
蔚来潜藏的危机:过去、现在到未来
第四大运营商,难成「鲶鱼」
open3d里pointcloud和numpy数组之间的转化
Maingene listed on the Hong Kong Stock Exchange: IPO with a market value of HK $4.3 billion was ignored by the market
华为能成“口红一哥”,或者“带货女王”吗?
[MySQL learning notes 23] index optimization