当前位置:网站首页>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
这次已经写了代码注释,就不单独拿出来一章讲解啦,其实是偷个小懒。
三、运行效果
边栏推荐
- QQ被盗号后群发黄图,大批用户“社死”
- Vector explanation + topic
- 最长连续序列
- Construction and management practice of ByteDance buried point data flow
- Could you tell me whether the batch addition of Oracle such as insert all was not blocked?
- 完整的模型训练套路(一)
- Leetcode (88) -- merge two ordered arrays
- Jackie Chan and fast brand, who is the Savior of Kwai?
- Facebook出手!自适应梯度打败人工调参
- 坐拥1200亿,她又要IPO敲钟了
猜你喜欢
美因基因港交所上市:市值43亿港元 IPO被市场忽略
After QQ was stolen, a large number of users "died"
2022年最新PyCharm激活破解码永久_详细安装教程(适用多版本)
蔚来潜藏的危机:过去、现在到未来
Q-Tester 3.2:适用于开发、生产和售后的诊断测试软件
With a return of 5000 times, the South African newspaper invested in Tencent to make a province
Facebook出手!自适应梯度打败人工调参
[C language] nextday problem
一文教你快速生成MySQL数据库关系图
Four visualization tools are recommended to solve 99% of large screen visualization projects!
随机推荐
Jingyuan's safe sprint to the Growth Enterprise Market: it plans to raise 400million yuan for investment and Yunyou software is the shareholder
Maingene listed on the Hong Kong Stock Exchange: IPO with a market value of HK $4.3 billion was ignored by the market
R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和一段文本内容横向组合起来形成最终结果图
Is PMP really useful?
5000倍回报,南非报业投资腾讯赚了一个省
Summary of technical difficulties of wearable neural signal and behavior data detection and recording system for birds in flight
力扣今日题-522. 最长特殊序列
Functools: high order functions and operations on callable objects (continuous updating ing...)
Send2vec tutorial
Which securities company is the largest and safest? How to open an account is the safest
名创优品通过上市聆讯:寻求双重主要上市 年营收91亿
【mysql学习笔记24】索引设计原则
云杉网络DeepFlow帮助5G核心网和电信云构建可观测性
[MySQL learning notes 24] index design principles
Leetcode (88) -- merge two ordered arrays
解决Unable to create process using ‘D:\Program File
[JS] Fibonacci sequence implementation (recursion and loop)
R语言ggplot2可视化:使用patchwork包将两个ggplot2可视化结果纵向堆叠起来(stacking)形成组合图、一个可视化结果堆叠在另外一个可视化结果上
Kwai investment e-commerce service provider Yixin optimization
【mysql学习笔记23】索引优化