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

边栏推荐
- 【mysql学习笔记24】索引设计原则
- MySQL主从切换的超详细步骤
- Kwai investment e-commerce service provider Yixin optimization
- Jackie Chan and fast brand, who is the Savior of Kwai?
- Introduction to common components of IOT low code platform
- 快手投资电商服务商易心优选
- Four visualization tools are recommended to solve 99% of large screen visualization projects!
- 使用Karmada实现Helm应用的跨集群部署
- Q-tester 3.2: applicable to development, production and after-sales diagnostic test software
- How to solve the following problems in the Seata database?
猜你喜欢
MySQL主从切换的超详细步骤

使用Karmada实现Helm应用的跨集群部署

Jingyuan's safe sprint to the Growth Enterprise Market: it plans to raise 400million yuan for investment and Yunyou software is the shareholder

With 120billion yuan, she will ring the bell for IPO again

Softing epgate Pb series Gateway - integrates the Profibus bus into the ethernet/ip network

vscode编写markdown文件并生成pdf

Performance comparison of deep learning models on cat and dog image data sets

dolphinscheduler2.X的安装(亲测有效)
![[Zhongyi Xinsheng] 5 SPI interface test TF Card](/img/d9/56ded362b3055f4f0efc3ce0eec5d5.jpg)
[Zhongyi Xinsheng] 5 SPI interface test TF Card

动力电池,是这样被“瓜分”的
随机推荐
成龙和快品牌,谁才是快手的救星?
High "green premium" of environmental protection products? How far is the low-carbon lifestyle from people
vscode编写markdown文件并生成pdf
js 判断字符串为空或者不为空
After nearly 20 years of operation, the Mars probe software based on win 98 has been upgraded for the first time
组合总和-Leetcode
Rails advanced -- framework theory cognition and construction scheme construction (I)
Is PMP really useful?
浪潮网络步步为赢
10 key points to effectively improve performance interview
Maingene listed on the Hong Kong Stock Exchange: IPO with a market value of HK $4.3 billion was ignored by the market
With a return of 5000 times, the South African newspaper invested in Tencent to make a province
张同学还没学会当主播
Express模板引擎
The boss told me three times: low key, low key, low key
WSUS客户端访问服务端异常报错-0x8024401f「建议收藏」
云杉网络DeepFlow帮助5G核心网和电信云构建可观测性
R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用回归系数及其标准误计算每个系数对应的Z统计量的值
R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和数据表格横向组合起来形成最终结果图
Q-Tester 3.2:适用于开发、生产和售后的诊断测试软件