当前位置:网站首页>MIPS汇编语言学习-03-循环
MIPS汇编语言学习-03-循环
2022-06-28 15:04:00 【阳光九叶草LXGZXJ】
一、前言
如何在电脑上运行MIPS汇编语言,这边不做赘述,请查阅之前的博客链接,里面有相关的安装包和运行方法:MIPS汇编语言学习-01-两数求和
二、源码
#功能实现:
#实现1累加到10000,最后打印累加结果
.text
#按照C语言的实现思路我们定义两个变量来Sum,i,MaxValue。
#现在我们用$t0 : Sum, $t1 : i, $t2 : MaxValue三个寄存器来进行对应。
li $t0, 0
li $t1, 1
li $t2, 10000
#现在自定义一个标签WhileLoop来进行执行循环体内的代码。
#需要实现的内容是:Sum = Sum + i; i = i + 1;
WhileLoop:
add $t0, $t0, $t1
add $t1, $t1, 1
#这边来写IF判断条件,i <= 100。
#ble函数的功能为实现小于等于,三个参数:
#第一个参数值小于等于第二个参数值,执行第三个参数的标签。
#第一个参数值小于等于第二个参数值,就不执行第三个参数标签,直接往下执行。
ble $t1, $t2, WhileLoop
#循环结束打印结果
#打印整数的方法在前面的一章讲过,大家可以翻阅一下。
li $v0, 1
move $a0, $t0
syscall
这次已经写了代码注释,就不单独拿出来一章讲解啦,其实是偷个小懒。
三、运行效果

边栏推荐
- Summary of technical difficulties of wearable neural signal and behavior data detection and recording system for birds in flight
- Construction and management practice of ByteDance buried point data flow
- 解决Unable to create process using ‘D:\Program File
- 抽奖动画 - 鲤鱼跳龙门
- 组合总和-Leetcode
- How can I get the stock account opening discount link? Is it safe to open a mobile account?
- R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和一段文本内容横向组合起来形成最终结果图
- Conversion between pointcloud and numpy arrays in open3d
- 浪擎与浪潮,一个从OEM到价值共生的生态样板
- Unable to create process using 'd:\program file
猜你喜欢

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

Vscode writes markdown file and generates pdf

老板囑咐了三遍:低調、低調、低調

2022年最新PyCharm激活破解码永久_详细安装教程(适用多版本)

Power battery is divided up like this

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

【算法篇】刷了两道大厂面试题,含泪 ”重学数组“

New offline retail stores take off against the trend, and consumption enthusiasm under the dark cloud of inflation
![[C language] how to generate normal or Gaussian random numbers](/img/31/964e0922e698a3746599b840501cdf.png)
[C language] how to generate normal or Gaussian random numbers
ORACLE中dbms_output.put_line输出问题的解决过程
随机推荐
Leetcode (167) -- sum of two numbers II - input ordered array
R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和一个plot函数可视化结果横向组合起来形成最终结果图、将两个可视的组合结果对齐
Steve Jobs of the United States, died; China jobs, sold
兼顾企业抗疫和发展的5个解决方案,来自IBM
spark sql 生成 json
计算器(力扣)
R语言ggplot2可视化:使用patchwork包将3个ggplot2可视化结果自定义组合起来构成组合图、两个子图横向组合后和另外一个图纵向组合构成最终组合图
spacy教程(持续更新ing...)
[C language] nextday problem
使用Karmada实现Helm应用的跨集群部署
Oracle11g数据库使用expdp每周进行数据备份并上传到备份服务器
字节跳动埋点数据流建设与治理实践
The latest pycharm activation cracking code in 2022 is permanent_ Detailed installation tutorial (applicable to multiple versions)
[JS] Fibonacci sequence implementation (recursion and loop)
How can I get the stock account opening discount link? Is it safe to open a mobile account?
Force deduction solution summary 522- longest special sequence II
Seata数据库中出现以下问题要怎么解决呀?
竞远安全冲刺创业板:拟募资4亿 启元投资与云游软件是股东
猫狗图像数据集上的深度学习模型性能对比
技术弄潮儿