您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 电子设计/PCB > mips微机原理实验报告
一、实验目的1.掌握QTSPIM的调试技术2.了解MIPS汇编语言与机器语言之间的对应关系3.掌握MIPS汇编程序设计4.了解C语言语句与汇编指令之间的关系5.熟悉常见的MIPS汇编指令6.掌握程序的内存映像二、实验任务用汇编程序实现以下伪代码:要求采用移位指令实现乘除法运算。intmain(){intK,Y;intZ[50];Y=56;for(k=0;k50;k++)Z[K]=Y-16*(K/4+210);}三、实验要求1.完成汇编语言程序设计、调试、测试全过程2.指出用户程序的内存映像,包括代码段和数据段3.完成软件实验报告四,实验思路初始化:在.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命令重新开始一轮计算退出:利用li$v0,10和syscall结束整个程序五、实验过程程序源代码:.data#定义用户数据段z:.space200.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($s0)#写进z[k]addi$s0,$s0,4#地址移一位addi$t0,$t0,1#k加1jloop#循环done:li$v010syscall调试过程:1.装载程序,选择file,reinitializeandloadfile2.运行程序:选择runandcontinue2.观察程序运行结果六.代码段内存映像[00400024]3c101001lui$16,4097[z];5:la$s0,z[00400028]34080000ori$8,$0,0;6:li$t0,0[0040002c]34090038ori$9,$0,56;7:li$t1,56[00400030]290a0032slti$10,$8,50;9:slti$t2,$t0,50[00400034]11400009beq$10,$0,36[done-0x00400034][00400038]00085882srl$11,$8,2;11:srl$t3,$t0,2[0040003c]216b00d2addi$11,$11,210;12:addi$t3,$t3,210[00400040]000b5900sll$11,$11,4;13:sll$t3,$t3,4[00400044]012b5822sub$11,$9,$11;14:sub$t3,$t1,$t3[00400048]ae0b0000sw$11,0($16);15:sw$t3,0($s0)[0040004c]22100004addi$16,$16,4;16:addi$s0,$s0,4[00400050]21080001addi$8,$8,1;17:addi$t0,$t0,1[00400054]0810000cj0x00400030[loop];18:jloop[00400058]3402000aori$2,$0,10;20:li$v010[0040005c]0000000csyscall;21:syscall七.数据段内存映像[10010000]fffff318fffff318fffff318fffff318[10010010]fffff308fffff308fffff308fffff308[10010020]fffff2f8fffff2f8fffff2f8fffff2f8[10010030]fffff2e8fffff2e8fffff2e8fffff2e8[10010040]fffff2d8fffff2d8fffff2d8fffff2d8[10010050]fffff2c8fffff2c8fffff2c8fffff2c8[10010060]fffff2b8fffff2b8fffff2b8fffff2b8[10010070]fffff2a8fffff2a8fffff2a8fffff2a8[10010080]fffff298fffff298fffff298fffff298[10010090]fffff288fffff288fffff288fffff288[100100a0]fffff278fffff278fffff278fffff278[100100b0]fffff268fffff268fffff268fffff268[100100c0]fffff258fffff258整理成表格可得:内存地址变量名(字)值0x10010000z[0]180x10010001z[0]f30x10010002z[0]ff0x10010003z[0]ff0x10010004z[1]180x10010005z[1]f30x10010006z[1]ff0x10010007z[1]ff0x10010008z[2]180x10010009z[2]f30x1001000Az[2]ff0x1001000Bz[2]ff0x1001000Cz[3]180x1001000Dz[3]f30x1001000Ez[3]ff0x1001000Fz[3]ff0x10010010z[4]080x10010011z[4]f30x10010012z[4]ff0x10010013z[4]ff0x10010014z[5]080x10010015z[5]f30x10010016z[5]ff0x10010017z[5]ff0x10010018z[6]080x10010019z[6]f30x1001001Az[6]ff0x1001001Bz[6]ff0x1001001Cz[7]080x1001001Dz[7]f30x1001001Ez[7]ff0x1001001Fz[7]ff0x10010020z[8]f80x10010021z[8]f30x10010022z[8]ff0x10010023z[8]ff0x10010024z[9]f80x10010025z[9]f20x10010026z[9]ff0x10010027z[9]ff0x10010028z[10]f80x10010029z[10]f20x1001002Az[10]ff0x1001002Bz[10]ff0x1001002Cz[11]f80x1001002Dz[11]f20x1001002Ez[11]ff0x1001002Fz[11]ff0x10010030z[12]e80x10010031z[12]f20x10010032z[12]ff0x10010033z[12]ff0x10010034z[13]e80x10010035z[13]f20x10010036z[13]ff0x10010037z[13]ff0x10010038z[14]e80x10010039z[14]f20x1001003Az[14]ff0x1001003Bz[14]ff0x1001003Cz[15]e80x1001003Dz[15]f20x1001003Ez[15]ff0x1001003Fz[15]ff0x10010040z[16]d80x10010041z[16]f20x10010042z[16]ff0x10010043z[16]ff0x10010044z[17]d80x10010045z[17]f20x10010046z[17]ff0x10010047z[17]ff0x10010048z[18]d80x10010049z[18]f20x1001004Az[18]ff0x1001004Bz[18]ff0x1001004Cz[19]d80x1001004Dz[19]f20x1001004Ez[19]ff0x1001004Fz[19]ff0x10010050z[20]c80x10010051z[20]f20x10010052z[20]ff0x10010053z[20]ff0x10010054z[21]c80x10010055z[21]f20x10010056z[21]ff0x10010057z[21]ff0x10010058z[22]c80x10010059z[22]f20x1001005Az[22]ff0x1001005Bz[22]ff0x1001005Cz[23]c80x1001005Dz[23]f20x1001005Ez[23]ff0x1001005Fz[23]ff0x10010060z[24]b80x10010061z[24]f20x10010062z[24]ff0x10010063z[24]ff0x10010064z[25]b80x10010065z[25]f20x10010066z[25]ff0x10010067z[25]ff0x10010068z[26]b80x10010069z[26]f20x1001006Az[26]ff0x1001006Bz[26]ff0x1001006Cz[27]b80x1001006Dz[27]f20x1001006Ez[27]ff0x1001006Fz[27]ff0x10010070z[28]a80x10010071z[28]f20x10010072z[28]ff0x10010073z[28]ff0x10010074z[29]a80x10010075z[29]f20x10010076z[29]ff0x10010077z[29]ff0x10010078z[30]a80x10010079z[30]f20x1001007Az[30]ff0x1001007Bz[30]ff0x1001007Cz[31]a80x1001007Dz[31]f20x1001007Ez[31]ff0x1001007Fz[31]ff0x10010080z[32]980x10010081z[32]f20x10010082z[32]ff0x10010083z[32]ff0x10010084z[33]980x10010085z[33]f20x10010086z[33]ff0x10010087z[33]ff0x10010088z[34]980x10010089z[34]f20x1001008Az[34]ff0x1001008Bz[34]ff0x1001008Cz[35]980x1001008Dz[35]f20x1001008Ez[35]ff0x1001008Fz[35]ff0x10010090z[36]880x10010091z[36]f20x10010092z[36]ff0x10010093z[36]ff0x10010094z[37]880x10010095z[37]f20x10010096z[37]ff0x10010097z[37]ff0x10010098z[38]880x10010099z[38]f20x1001009Az[38]ff0x1001009Bz[38]ff0x1001009Cz[39]880x1001009Dz[39]f20x1001009Ez[39]ff0x1001009Fz[39]ff0x100100A0z[40]780x100100A1z[40]f20x100100A2z[40]ff0x100100A3z[40]ff0x100100A4z[41]780x1
本文标题:mips微机原理实验报告
链接地址:https://www.777doc.com/doc-7048976 .html