指令集多來源格式整齊_第1頁
指令集多來源格式整齊_第2頁
指令集多來源格式整齊_第3頁
指令集多來源格式整齊_第4頁
指令集多來源格式整齊_第5頁
已閱讀5頁,還剩1頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、MIPS32指令集MIPS指令可以分成以下各類:    空操作no-op;    寄存器寄存器傳輸:用得很廣,包括條件傳輸在內(nèi);    常數(shù)加載:作為數(shù)值和地址的整型立即數(shù);    算術(shù)邏輯指令;    整數(shù)乘法、除法和求余數(shù);    整數(shù)乘加;    加載和存儲;    跳轉(zhuǎn)、子程序調(diào)用和分支;    斷點和自陷; 

2、   CP0功能:CPU控制指令    浮點;    用戶態(tài)的受限訪問:rdhwr和synci注:64位版本開頭以“d”表示,無符號數(shù)以“u”結(jié)尾,立即數(shù)通常以“i”結(jié)尾,字節(jié)操作以“b”結(jié)尾,雙字操作以“d”結(jié)尾,字操作以“w”結(jié)尾1、空操作:nop:相當(dāng)于 sll zero,zero,o,                   

3、; ssnop: equals sll zero,zero,1.      這個指令不得與其它指令同時發(fā)送,這樣就保證了其運行要花費至少一個時鐘周期。這在簡單的流水線的CPU上無關(guān)緊要,但在復(fù)雜些的實現(xiàn)上對于實現(xiàn)強(qiáng)制的延時很有用。2、寄存器寄存器傳送:      move: 通常用跟$zero寄存器的or來實現(xiàn),或者用addu。      movf, movt, movn, movz: 條件傳送。3、常數(shù)加載:   

4、   dla、la: 用來加載程序中某些帶標(biāo)號的位置或者變量的地址的宏指令;      dli、li: 裝入立即數(shù)常數(shù),這是一個宏指令;      lui: 把立即數(shù)加載到寄存器高位。4、算術(shù)邏輯運算:      add、addi、dadd、daddi、addu、addiu、daddu、daddiu、dsub、sub、subu:加法指令和減法指令;      abs,dabs:

5、絕對值;      dneg、neg、negu:取相反數(shù);      and、andi、or、ori、xor、nor:逐位邏輯操作指令;      drol、rol、ror:循環(huán)移位指令;      sll、srl、sra:移位。5、條件設(shè)置指令:      slt、slti、sltiu、sltu、seq、sge、sle、sne:條件設(shè)置。6、整數(shù)

6、乘法、除法和求余數(shù):      div、mul、rem等等。7、整數(shù)乘加(累加):      mad等。8、加載和存儲:      lb、ld、ldl、ldr、sdl、sdr、lh、lhu、ll、sc、pref、sb等操作。9、浮點加載和存儲:      l.d、l.s、s.d、s.s等常用MIPS指令集及格式:MIPS 指令集(共31條)助記符指令格式示例示例含義操作及其解釋Bit #31.26

7、25.2120.1615.1110.65.0   R-typeoprsrtrdshamtfunc   add000000rsrtrd00000100000 add $1,$2,$3 $1=$2+$3 rd <- rs + rt   ;其中rs$2,rt=$3, rd=$1addu000000rsrtrd00000100001 addu $1,$2,$3 $1=$2+$3 rd <- rs + rt   ;

8、其中rs$2,rt=$3, rd=$1,無符號數(shù)sub000000rsrtrd00000100010 sub $1,$2,$3 $1=$2-$3 rd <- rs - rt   ;其中rs$2,rt=$3, rd=$1subu000000rsrtrd00000100011 subu $1,$2,$3 $1=$2-$3 rd <- rs - rt   ;其中rs$2,rt=$3, rd=$1,無符號數(shù)and000000rsrtrd00000100100 a

9、nd $1,$2,$3 $1=$2 & $3 rd <- rs & rt   ;其中rs$2,rt=$3, rd=$1or000000rsrtrd00000100101 or $1,$2,$3 $1=$2 | $3 rd <- rs | rt   ;其中rs$2,rt=$3, rd=$1xor000000rsrtrd00000100110 xor $1,$2,$3 $1=$2  

10、$3 rd <- rs xor rt   ;其中rs$2,rt=$3, rd=$1(異或)nor000000rsrtrd00000100111 nor $1,$2,$3 $1=($2 | $3) rd <- not(rs | rt)   ;其中rs$2,rt=$3, rd=$1(或非)slt000000rsrtrd00000101010 slt $1,$2,$3 if($2<$3)   $1=1 e

11、lse   $1=0 if (rs < rt) rd=1 else rd=0 ;其中rs$2,rt=$3, rd=$1sltu000000rsrtrd00000101011 sltu $1,$2,$3 if($2<$3)   $1=1 else   $1=0 if (rs < rt) rd=1 else rd=0 ;其中rs$2,rt=$3, rd=$1  (無符號數(shù))sll00

12、000000000rtrdshamt000000 sll $1,$2,10 $1=$2<<10 rd <- rt << shamt  ;shamt存放移位的位數(shù),  也就是指令中的立即數(shù),其中rt=$2, rd=$1srl00000000000rtrdshamt000010 srl $1,$2,10 $1=$2>>10 rd <- rt >> shamt ;(logical) ,其中rt=$2, rd=$1sra00000000000rtrdsh

13、amt000011 sra $1,$2,10 $1=$2>>10 rd <- rt >> shamt  ;(arithmetic) 注意符號位保留 其中rt=$2, rd=$1sllv000000rsrtrd00000000100 sllv $1,$2,$3 $1=$2<<$3 rd <- rt << rs  ;其中rs$3,rt=$2, rd=$1srlv000000rsrtrd00000000110 s

14、rlv $1,$2,$3 $1=$2>>$3 rd <- rt >> rs  ;(logical)其中rs$3,rt=$2, rd=$1srav000000rsrtrd00000000111 srav $1,$2,$3 $1=$2>>$3 rd <- rt >> rs  ;(arithmetic) 注意符號位保留 其中rs$3,rt=$2, rd=$1jr000000rs000000000000000001

15、000 jr $31 goto $31 PC <- rsI-typeoprsrtimmediate   addi001000rsrtimmediate addi $1,$2,100 $1=$2+100 rt <- rs + (sign-extend)immediate ;其中rt=$1,rs=$2addiu001001rsrtimmediateaddiu $1,$2,100 $1=$2+100 rt <- r

16、s + (zero-extend)immediate ;其中rt=$1,rs=$2andi001100rsrtimmediate andi $1,$2,10 $1=$2 & 10 rt <- rs & (zero-extend)immediate ;其中rt=$1,rs=$2ori001101rsrtimmediate andi $1,$2,10 $1=$2 | 10 rt <- rs | (zero-extend)immediate ;其中rt=$1,rs

17、=$2xori001110rsrtimmediate andi $1,$2,10 $1=$2 10 rt <- rs xor (zero-extend)immediate ;其中rt=$1,rs=$2lui00111100000rtimmediate lui $1,100 $1=100*65536 rt <- immediate*65536 ;將16位立即數(shù)放到目標(biāo)寄存器高16         

18、位,目標(biāo)寄存器的低16位填0lw100011rsrtimmediate lw $1,10($2) $1=memory$2 +10 rt <- memoryrs + (sign-extend)immediate ;rt=$1,rs=$2sw101011rsrtimmediate sw $1,10($2) memory$2+10 =$1 memoryrs + (sign-extend)immediate <- rt ;rt=$1,rs=$2beq000100rsrti

19、mmediate beq $1,$2,10 if($1=$2)   goto PC+4+40 if (rs = rt) PC <- PC+4 + (sign-extend)immediate<<2 bne000101rsrtimmediate bne $1,$2,10 if($1!=$2) goto PC+4+40 if (rs != rt) PC <- PC+4 + (sign-extend)immediate<<2&

20、#160;slti001010rsrtimmediate slti $1,$2,10 if($2<10)   $1=1 else   $1=0 if (rs <(sign-extend)immediate) rt=1 else rt=0 ;   其中rs$2,rt=$1sltiu001011rsrtimmediate sltiu $1,$2,10 if($2<10)   $1=1 

21、;else   $1=0 if (rs <(zero-extend)immediate) rt=1 else rt=0 ;  其中rs$2,rt=$1J-typeopaddress   j000010address j 10000 goto 10000 PC <- (PC+4)31.28,address,0,0   ;address=10000/4jal000011address jal

22、0;10000 $31<-PC+4; goto 10000 $31<-PC+4;PC <- (PC+4)31.28,address,0,0   ;address=10000/4更全的MIPS匯編指令A(yù)rithmetic Instructionsabs des, src1 # des gets the absolute value of src1.add(u) des, src1, src2 # des gets src1 + src2.addi $t2,$t3,5 # $t2 = $t3 + 5 加16位立

23、即數(shù)addiu $t2,$t3,5 # $t2 = $t3 + 5 加16位無符號立即數(shù)sub(u) des, src1, src2 # des gets src1 - src2.div(u) src1, reg2 # Divide src1 by reg2, leaving the quotient in register# lo and the remainder in register hi.div(u) des, src1, src2 # des gets src1 / src2. mul des, src1, src2 # des gets src1 * src2.mulo des,

24、 src1, src2 # des gets src1 * src2, with overflow.mult(u) src1, reg2 # Multiply src1 and reg2, leaving the low-order word# in register lo and the high-order word in register hi.rem(u) des, src1, src2 # des gets the remainder of dividing src1 by src2.neg(u) des, src1 # des gets the negative of src1.a

25、nd des, src1, src2 # des gets the bitwise and of src1 and src2.nor des, src1, src2 # des gets the bitwise logical nor of src1 and src2.not des, src1 # des gets the bitwise logical negation of src1.or des, src1, src2 # des gets the bitwise logical or of src1 and src2.xor des, src1, src2 # des gets th

26、e bitwise exclusive or of src1 and src2.rol des, src1, src2 # des gets the result of rotating left the contents of src1 by src2 bits.ror des, src1, src2 # des gets the result of rotating right the contents of src1 by src2 bits.sll des, src1, src2 # des gets src1 shifted left by src2 bits.sra des, sr

27、c1, src2 # Right shift arithmetic.srl des, src1, src2 # Right shift logical.sllv des, src1, src2 # $t0 = $t1 << $t3,shift left logicalsrlv des, src1, src2 # $t0 = $t1 >> $t3,shift right logicalsrav des, src1, src2 # $t0 = $t1 >> $t3,shift right arithm.Comparison Instructionsseq des

28、, src1, src2 # des 1 if src1 = src2, 0 otherwise.sne des, src1, src2 # des 1 if src1 != src2, 0 otherwise.sge(u) des, src1, src2 # des 1 if src1 >= src2, 0 otherwise.sgt(u) des, src1, src2 # des 1 if src1 > src2, 0 otherwise.sle(u) des, src1, src2 # des 1 if src1 <= src2, 0 otherwise.slt(u)

29、 des, src1, src2 # des 1 if src1 < src2, 0 otherwise. slti $t1,$t2,10 # 與立即數(shù)比較Branch and Jump Instructionsb lab # Unconditional branch to lab.beq src1, src2, lab # Branch to lab if src1 = src2 .bne src1, src2, lab # Branch to lab if src1 != src2 .bge(u) src1, src2, lab # Branch to lab if src1 >

30、;= src2 .bgt(u) src1, src2, lab # Branch to lab if src1 > src2 .ble(u) src1, src2, lab # Branch to lab if src1 <= src2 .blt(u) src1, src2, lab # Branch to lab if src1 < src2 .beqz src1, lab # Branch to lab if src1 = 0.bnez src1, lab # Branch to lab if src1 != 0.bgez src1, lab # Branch to la

31、b if src1 >= 0.bgtz src1, lab # Branch to lab if src1 > 0.blez src1, lab # Branch to lab if src1 <= 0.bltz src1, lab # Branch to lab if src1 < 0.bgezal src1, lab # If src1 >= 0, then put the address of the next instruction# into $ra and branch to lab.bgtzal src1, lab # If src1 > 0,

32、 then put the address of the next instruction# into $ra and branch to lab.bltzal src1, lab # If src1 < 0, then put the address of the next instruction# into $ra and branch to lab.j label # Jump to label lab.jr src1 # Jump to location src1.jal label # Jump to label lab, and store the address of th

33、e next instruction in $ra.jalr src1 # Jump to location src1, and store the address of the next instruction in $ra.Load, Store, and Data Movement(reg) $ Contents of reg.const $ A constant address.const(reg) $ const + contents of reg.symbol $ The address of symbol.symbol+const $ The address of symbol

34、+ const.symbol+const(reg) $ The address of symbol + const + contents of reg.la des, addr # Load the address of a label.lb(u) des, addr # Load the byte at addr into des.lh(u) des, addr # Load the halfword at addr into des.li des, const # Load the constant const into des.lui des, const # Load the constant const into the upper halfword of des,# and set the lower halfword of des to 0.lw des, addr # Load the word at addr into des.lwl des, addrlwr des, addrulh(u) des, addr # Load the halfword starting at the (pos

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論