Experiment 2: MIPS MIPS instruction set architecture and

Experiment 2: MIPS MIPS instruction set architecture and

I. Purpose

  • (1) to understand and be familiar with the instruction level simulator
  • (2) MIPSsim familiar with the operation and use of simulators
  • (3) system and its characteristics are familiar MIPS instruction, to deepen understanding of the semantics of the MIPS instruction operation
  • (4) be familiar with MIPS architecture

II. Experimental details and steps

To read the first method MIPSsim simulator, and then learn MIPSsim command system.
(1), start MIPSsim.
(2) Select "Configuration" -> "water" option, the simulator work of non-flowing water ways.
(3), described with reference to the use of familiar MIPSsim operation and use of the simulator.
(4), select "File" -> "Load" option, load the sample program alltest.asm, and then view the "code" window, to see where the program is located.
(5), see "register" the value of the PC register window: [PC] = 0x00000000.
Here Insert Picture Description
(6), execute load and store instructions, the following steps:
1) a single step instruction (F7).

{, Literal stored with complement form; ADDIU: r 8 , r8, r0,128
ADDIU GPR is done, immediate unsigned addition operation, the immediate field is sign, sign extension need to do so. r8 = r0 + 124}

Here Insert Picture Description
2) as the next instruction address 0x00000004, there is one (yes, no) Loading byte symbol (byte, halfword, word) instruction (LB byte read from the data memory into a register, is read out the signed data)
3) single-step execution of an instruction (F7).
Here Insert Picture Description
4) Check the value of R1, [R1] = 0xFFFFFFFFFFFFFF80 (decimal: -128).

{一个字节的范围带符号的就是
-128到+127,16进制的80转换成十进制为+128,一个字节的范围为-128~+127;16进制的80转换成二进制为10000000,补码表示法得知
10000000 就是-128的补码咯 }

5)下一条指令地址为 0x00000008 ,是一条 无 (有,无)符号载入 字 (字节,半字,字)指令。{LW:从存储器中读取一个字的数据到寄存器中}
6)单步执行1条指令。
Here Insert Picture Description
7)查看R1的值,[R1]= 0x0000000000000080 (二进制的值为:128) 。
8)下一条指令地址为 0x0000000C ,是一条 无 (有,无)符号载入 字节 (字节,半字,字)指令。
{LBU功能与LB指令相同,但读出的是不带符号的数据}
9)单步执行1条指令。
Here Insert Picture Description
10)查看R1的值,[R1]= 128(十进制) /0x0000000000000080 (十六进制) 。
11)单步执行1条指令。
Here Insert Picture Description
12)下一条指令地址为 0x00000014 ,是一条保存 字 (字节,半字,字)指令。
13)单步执行一条指令。
14)查看内存BUFFER处字的值,值为 0X00000080 。

(7)、执行算术运算类指令。步骤如下:
1)双击“寄存器”窗口中的R1,将其值修改为2。
2)双击“寄存器”窗口中的R2,将其值修改为3。
3)单步执行一条指令。
4)下一条指令地址为 0x00000020 ,是一条加法指令。
5)单步执行一条指令。
Here Insert Picture Description
6)查看R3的值,[R3]= 5
Here Insert Picture Description
7)下一条指令地址为 0x00000024 ,是一条乘法指令。
8)单步执行一条指令。
Here Insert Picture Description
9)查看LO、HI的值,[LO]= 0x0000000000000006 ,[HI]= 0x0000000000000000 。
(8)、执行逻辑运算类指令。步骤如下:
1)双击“寄存器”窗口中的R1,将其值修改为0xFFFF0000。
2)双击“寄存器”窗口中的R2,将其值修改为0xFF00FF00。
3)单步执行一条指令。
Here Insert Picture Description
4)下一条指令地址为 0x00000030 ,是一条逻辑与运算指令,第二个操作数寻址方式是 寄存器直接寻址 (寄存器直接寻址,立即数寻址)。
5)单步执行一条指令。Here Insert Picture Description
6)查看R3的值,[R3]= 0x00000000FF000000 。
7)下一条指令地址为 0x00000034 ,是一条逻辑或指令,第二个操作数寻址方式是 立即数寻址 (寄存器直接寻址,立即数寻址)。
8)单步执行一条指令。Here Insert Picture Description
9)查看R3的值,[R3]= 0x0000000000000000 。
(9)、执行控制转移类指令。步骤如下:
1)双击“寄存器”窗口中R1,将其值修改为2。
2)双击“寄存器”窗口中R2,将其值修改为2。
3)单步执行一条指令。
Here Insert Picture Description
4)下一条指令地址为 0x00000040 ,是一条BEQ指令,其测试条件是 两个操作数相等 。
5) 单步执行1条指令。Here Insert Picture Description
6) 查看PC的值,[PC]= 0x0000004C ,表明分支 成功 (成功,失败)。
7) 一条指令是一条BGEZ指令,其测试条件是 大于等于零转移 ,目标地址为 0x00000058 。
8) 单步执行1条指令。Here Insert Picture Description
9) 查看PC的值,[PC]= 0x00000058 ,表明分支 成功 (成功,失败)。
10) 下一条指令是一条BGEZAL指令,其测试条件是 大于等于零转移并链接 ,目标地址为 0x00000064 。 Here Insert Picture Description
11) 单步执行1条指令。
Here Insert Picture Description
12) 查看PC的值,[PC]= 0x00000068 ,表明分支 成功 (成功,失败);查看R31的值,[R31]= 92 。
13) 单步执行1条指令。Here Insert Picture Description
14)查看R1的值,[R1]= 116 。
15)下一条指令地址为 0x00000068 ,是一条JALR指令,保存目标地址的寄存器为R1 ,保存返回地址的目标寄存器为R3。
16)单步执行1条指令。
Here Insert Picture Description
17)查看PC和R3的值,[PC]= 0x00000074 ,[R3]=108 。

三、实验结果分析

实验结果分析
ADDIU : r 8 , r8, r0,124 ADDIU是GPR和立即数做无符号加法操作,但立即数字段是有符号的,所以需要做符号扩展。r8=r0+124
LB r 1 , 0 ( r1,0( r8) 从存储器中r8读取一个字节的数据(带符号)到寄存器中r1
LW r 1 , 0 ( r1,0( r8) 从存储器中r8读取一个字的数据(不带符号)到寄存器中r1
LBU r 1 , 0 ( r1,0( r8) 从存储器中r8读取一个字节的数据(不带符号)到寄存器中r1
ADDIU : r 8 , r8, r0,128 ADDIU是GPR和立即数做无符号加法操作,但立即数字段是有符号的,所以需要做符号扩展。r8=r0+128
SW r 1 , 0 ( r1,0( r8):把一个字的数据从寄存器存储到存储器中
BEQ ,$r0, $r0,PROG2:条件转移指令,当两个寄存器内容相等时转移发生
-》》》跳转到PROG2
DADD $r3 $r1 r 2 The Two More set point send Deposit Device of Inside r2 把两个定点寄存器的内容相加,也就是定点加 r3 =$r1+ $r2 =128
DMULT $r1 r 2 r 1 = 128 r 2 = 0 B E Q , r2 两个定点寄存器的内容相乘,也就是定点乘r1=128 r2 =0 BEQ , r0, $r0,PROG3:条件转移指令,当两个寄存器内容相等时转移发生
-》》》跳转到PROG3
AND $r3 $r1 r 2 ( r2 与运算,两个寄存器中的内容相与( r3=$r1 & $r2) r1=128 r2=0 r3=0 两位同时为“1”,结果才为“1”,否则为0
ANDI $r3 r 10 B E Q , r1 0 一个寄存器中的内容与一个立即数相与 BEQ , r0, $r0,PROG4:条件转移指令,当两个寄存器内容相等时转移发生
-》》》跳转到PROG4
BEQ $r1 r 22 , r2 2 条件转移指令,当两个寄存器内容相等时转移发生, r1不等于$r2不发生
SLL $r0 $r0 0 逻辑左移
SLL $r0 $r0 0 逻辑左移
BGEZ $r1 2 跳转指令
-》》》跳转到label2
BGEZAL $r1 2 条件转移指令
-》》》跳转到label3
ADDIU $r1 $r0 116 r1=r0+116=116
JALR $r3 $r1 使用寄存器的跳转指令,并且带有链接功能,指令的跳转地址在寄存器中,跳转发生时指令的放回地址放在R31这个寄存器中
Teq :异常相关指令

四.实验心得

Basic Operation and use MIPSsim simulator; single-step execution, a loader, and the flow configuration; familiar MIPS instruction; enhancement of understanding of the semantics of the MIPS instruction operation; and code area, were analyzed register, but to keep this part of the clock cycle to understand is not very clear; resolve in future experiments; thinking LB, byte, word, double word how, as well as unsigned viewing, as well as how to view the contents of buffer; then by the code area symbol of self-learning instruction; and the ARM had a very good review; understanding LW, meaning LB, LU, ADDU, ADDIU, SLL, MUL, BEQ, and other simple instruction is analyzed; there remains changing register values ​​of the step portion is not clear and detailed; continuing need to understand the next session;

Published 58 original articles · won praise 20 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_40709110/article/details/103265177