《mips微机原理实验报告(共8页).docx》由会员分享,可在线阅读,更多相关《mips微机原理实验报告(共8页).docx(8页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上一、实验目的1.掌握QTSPIM的调试技术2.了解MIPS汇编语言与机器语言之间的对应关系3.掌握MIPS汇编程序设计4.了解C语言语句与汇编指令之间的关系5.熟悉常见的MIPS汇编指令6.掌握程序的内存映像二、实验任务 用汇编程序实现以下伪代码:要求采用移位指令实现乘除法运算。int main()int K, Y ;int Z50 ;Y = 56;for(k=0;k50;k+)ZK = Y - 16 * ( K / 4 + 210) ;三、实验要求1.完成汇编语言程序设计、调试、测试全过程2.指出用户程序的内存映像,包括代码段和数据段3.完成软件实验报告四,实验思路
2、初始化:在.data里声明一个长度为200的空间勇于存储Z数组,取得Z数组的地址,认为寄存器$s1,$s2分别存储k的值和y的值,对k和y的操作直接改变寄存器的值,$s0存储Z数组的地址。计算:根据题目所提供的算式一步一步计算,所得中间结果寄存在寄存器$t0中。针对乘除法由于乘数和除数都是2的整数指数幂函数倍,所以分别采用左移(sll)和右移(srl)来计算。存储:每次计算完算式的答案后用sw命令将答案存储在内存中的对应地址处自增:每一次计算后k自动增1,$s0寄存器存储的相应Z数组地址加4跳转判断:如果k大于等于50,则跳到exit处结束程序,如果k小于50则利用j命令重新开始一轮计算退出:
3、利用 li $v0,10 和 syscall 结束整个程序五、实验过程程序源代码:.data #定义用户数据段z:.space 200.textmain:la $s0,z #$s0=addrzli $t0,0 #$s1=k=0li $t1,56 #$s2=y=56loop:slti $t2,$t0,50 #判断k是否小于50beq $t2,$0,done #当k大于等于50时跳转srl $t3,$t0,2 #k/4addi $t3,$t3,210 #k/4+210sll $t3,$t3,4 #16*(k/4+210)sub $t3,$t1,$t3 #y-16*(k/4+210)sw $t3,0
4、($s0) #写进zkaddi $s0,$s0,4 #地址移一位addi $t0,$t0,1 #k加1j loop #循环done:li $v0 10syscall调试过程:1. 装载程序,选择file,reinitialize and load file2. 运行程序:选择run and continue2.观察程序运行结果六代码段内存映像 3clui $16, 4097 z; 5: la $s0,z ori $8, $0, 0; 6: li $t0,0 c ori $9, $0, 56; 7: li $t1,56 290a0032slti $10, $8, 50; 9: slti $t2,
5、$t0,50 beq $10, $0, 36 done-0x srl $11, $8, 2; 11: srl $t3,$t0,2 c 216b00d2addi $11, $11, 210; 12: addi $t3,$t3,210 000b5900sll $11, $11, 4; 13: sll $t3,$t3,4 012b5822sub $11, $9, $11; 14: sub $t3,$t1,$t3 ae0b0000sw $11, 0($16); 15: sw $t3,0($s0) c addi $16, $16, 4; 16: addi $s0,$s0,4 addi $8, $8, 1
6、; 17: addi $t0,$t0,1 cj 0x loop; 18: j loop aori $2, $0, 10; 20: li $v0 10 c csyscall; 21: syscall七数据段内存映像 fffff318 fffff318 fffff318 fffff318 fffff308 fffff308 fffff308 fffff308 fffff2f8 fffff2f8 fffff2f8 fffff2f8 fffff2e8 fffff2e8 fffff2e8 fffff2e8 fffff2d8 fffff2d8 fffff2d8 fffff2d8 fffff2c8 ffff
7、f2c8 fffff2c8 fffff2c8 fffff2b8 fffff2b8 fffff2b8 fffff2b8 fffff2a8 fffff2a8 fffff2a8 fffff2a8 fffff298 fffff298 fffff298 fffff298 fffff288 fffff288 fffff288 fffff288 a0 fffff278 fffff278 fffff278 fffff278 b0 fffff268 fffff268 fffff268 fffff268 c0 fffff258 fffff258整理成表格可得:内存地址变量名(字)值0xz0180xz0f30xz0
8、ff0xz0ff0xz1180xz1f30xz1ff0xz1ff0xz2180xz2f30xAz2ff0xBz2ff0xCz3180xDz3f30xEz3ff0xFz3ff0xz4080xz4f30xz4ff0xz4ff0xz5080xz5f30xz5ff0xz5ff0xz6080xz6f30xAz6ff0xBz6ff0xCz7080xDz7f30xEz7ff0xFz7ff0xz8f80xz8f30xz8ff0xz8ff0xz9f80xz9f20xz9ff0xz9ff0xz10f80xz10f20xAz10ff0xBz10ff0xCz11f80xDz11f20xEz11ff0xFz11ff0x
9、z12e80xz12f20xz12ff0xz12ff0xz13e80xz13f20xz13ff0xz13ff0xz14e80xz14f20xAz14ff0xBz14ff0xCz15e80xDz15f20xEz15ff0xFz15ff0xz16d80xz16f20xz16ff0xz16ff0xz17d80xz17f20xz17ff0xz17ff0xz18d80xz18f20xAz18ff0xBz18ff0xCz19d80xDz19f20xEz19ff0xFz19ff0xz20c80xz20f20xz20ff0xz20ff0xz21c80xz21f20xz21ff0xz21ff0xz22c80xz
10、22f20xAz22ff0xBz22ff0xCz23c80xDz23f20xEz23ff0xFz23ff0xz24b80xz24f20xz24ff0xz24ff0xz25b80xz25f20xz25ff0xz25ff0xz26b80xz26f20xAz26ff0xBz26ff0xCz27b80xDz27f20xEz27ff0xFz27ff0xz28a80xz28f20xz28ff0xz28ff0xz29a80xz29f20xz29ff0xz29ff0xz30a80xz30f20xAz30ff0xBz30ff0xCz31a80xDz31f20xEz31ff0xFz31ff0xz32980xz32
11、f20xz32ff0xz32ff0xz33980xz33f20xz33ff0xz33ff0xz34980xz34f20xAz34ff0xBz34ff0xCz35980xDz35f20xEz35ff0xFz35ff0xz36880xz36f20xz36ff0xz36ff0xz37880xz37f20xz37ff0xz37ff0xz38880xz38f20xAz38ff0xBz38ff0xCz39880xDz39f20xEz39ff0xFz39ff0xA0z40780xA1z40f20xA2z40ff0xA3z40ff0xA4z41780xA5z41f20xA6z41ff0xA7z41ff0xA8
12、z42780xA9z42f20xAAz42ff0xABz42ff0xACz43780xADz43f20xAEz43ff0xAFz43ff0xB0z44680xB1z44f20xB2z44ff0xB3z44ff0xB4z45680xB5z45f20xB6z45ff0xB7z45ff0xB8z46680xB9z46f20xBAz46ff0xBBz46ff0xBCz47680xBDz47f20xBEz47ff0xBFz47ff0xC0z48580xC1z48f20xC2z48ff0xC3z48ff0xC4z49580xC5z49f20xC6z49ff0xC7z49ff八、实验总结 通过这次实验,加深了我对微机原理的理论学习和汇编代码 的理解,练习了Qtspim软件的使用,对以后的学习有很大的帮助。这次实验的内容相对比较简单,原理容易理解,编译的过程中遇到了一点困难,不过按照老师的方法解决了。专心-专注-专业