已閱讀5頁,還剩1頁未讀, 繼續(xù)免費閱讀
版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
MIPS32指令集MIPS指令可以分成以下各類: 空操作no-op; 寄存器寄存器傳輸:用得很廣,包括條件傳輸在內(nèi); 常數(shù)加載:作為數(shù)值和地址的整型立即數(shù); 算術邏輯指令; 整數(shù)乘法、除法和求余數(shù); 整數(shù)乘加; 加載和存儲; 跳轉(zhuǎn)、子程序調(diào)用和分支; 斷點和自陷; CP0功能:CPU控制指令 浮點; 用戶態(tài)的受限訪問:rdhwr和synci注:64位版本開頭以“d”表示,無符號數(shù)以“u”結(jié)尾,立即數(shù)通常以“i”結(jié)尾,字節(jié)操作以“b”結(jié)尾,雙字操作以“d”結(jié)尾,字操作以“w”結(jié)尾1、空操作:nop:相當于 sll zero,zero,o, ssnop: equals sll zero,zero,1. 這個指令不得與其它指令同時發(fā)送,這樣就保證了其運行要花費至少一個時鐘周期。這在簡單的流水線的CPU上無關緊要,但在復雜些的實現(xiàn)上對于實現(xiàn)強制的延時很有用。2、寄存器寄存器傳送: move: 通常用跟$zero寄存器的or來實現(xiàn),或者用addu。 movf, movt, movn, movz: 條件傳送。3、常數(shù)加載: dla、la: 用來加載程序中某些帶標號的位置或者變量的地址的宏指令; dli、li: 裝入立即數(shù)常數(shù),這是一個宏指令; lui: 把立即數(shù)加載到寄存器高位。4、算術邏輯運算: add、addi、dadd、daddi、addu、addiu、daddu、daddiu、dsub、sub、subu:加法指令和減法指令; abs,dabs:絕對值; dneg、neg、negu:取相反數(shù); and、andi、or、ori、xor、nor:逐位邏輯操作指令; drol、rol、ror:循環(huán)移位指令; sll、srl、sra:移位。5、條件設置指令: slt、slti、sltiu、sltu、seq、sge、sle、sne:條件設置。6、整數(shù)乘法、除法和求余數(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.2625.2120.1615.1110.65.0R-typeoprsrtrdshamtfuncadd000000rsrtrd00000100000add $1,$2,$3$1=$2+$3rd - rs + rt;其中rs$2,rt=$3, rd=$1addu000000rsrtrd00000100001addu $1,$2,$3$1=$2+$3rd - rs + rt;其中rs$2,rt=$3, rd=$1,無符號數(shù)sub000000rsrtrd00000100010sub $1,$2,$3$1=$2-$3rd - rs - rt;其中rs$2,rt=$3, rd=$1subu000000rsrtrd00000100011subu $1,$2,$3$1=$2-$3rd - rs - rt;其中rs$2,rt=$3, rd=$1,無符號數(shù)and000000rsrtrd00000100100and $1,$2,$3$1=$2&$3rd - rs & rt;其中rs$2,rt=$3, rd=$1or000000rsrtrd00000100101or $1,$2,$3$1=$2|$3rd - rs | rt;其中rs$2,rt=$3, rd=$1xor000000rsrtrd00000100110xor $1,$2,$3$1=$2$3rd - rs xor rt;其中rs$2,rt=$3, rd=$1(異或)nor000000rsrtrd00000100111nor $1,$2,$3$1=($2|$3)rd - not(rs | rt);其中rs$2,rt=$3, rd=$1(或非)slt000000rsrtrd00000101010slt $1,$2,$3if($2$3)$1=1else$1=0if (rs rt) rd=1elserd=0 ;其中rs$2,rt=$3, rd=$1sltu000000rsrtrd00000101011sltu $1,$2,$3if($2$3)$1=1else$1=0if (rs rt) rd=1elserd=0 ;其中rs$2,rt=$3, rd=$1(無符號數(shù))sll00000000000rtrdshamt000000sll $1,$2,10$1=$210rd - rt 10rd shamt ;(logical) ,其中rt=$2, rd=$1sra00000000000rtrdshamt000011sra $1,$2,10$1=$210rd shamt ;(arithmetic)注意符號位保留其中rt=$2, rd=$1sllv000000rsrtrd00000000100sllv $1,$2,$3$1=$2$3rd - rt$3rd rs;(logical)其中rs$3,rt=$2, rd=$1srav000000rsrtrd00000000111srav $1,$2,$3$1=$2$3rd rs;(arithmetic)注意符號位保留其中rs$3,rt=$2, rd=$1jr000000rs000000000000000001000jr$31goto$31PC -rsI-typeoprsrtimmediateaddi001000rsrtimmediateaddi$1,$2,100$1=$2+100rt - rs + (sign-extend)immediate;其中rt=$1,rs=$2addiu001001rsrtimmediateaddiu$1,$2,100$1=$2+100rt - rs + (zero-extend)immediate;其中rt=$1,rs=$2andi001100rsrtimmediateandi$1,$2,10$1=$2 & 10rt - rs & (zero-extend)immediate;其中rt=$1,rs=$2ori001101rsrtimmediateandi$1,$2,10$1=$2 | 10rt - rs | (zero-extend)immediate;其中rt=$1,rs=$2xori001110rsrtimmediateandi$1,$2,10$1=$2 10rt - rs xor (zero-extend)immediate;其中rt=$1,rs=$2lui00111100000rtimmediatelui$1,100$1=100*65536rt - immediate*65536;將16位立即數(shù)放到目標寄存器高16位,目標寄存器的低16位填0lw100011rsrtimmediatelw$1,10($2)$1=memory$2+10rt - memoryrs + (sign-extend)immediate;rt=$1,rs=$2sw101011rsrtimmediatesw$1,10($2)memory$2+10=$1memoryrs + (sign-extend)immediate - rt;rt=$1,rs=$2beq000100rsrtimmediatebeq$1,$2,10if($1=$2) gotoPC+4+40if (rs = rt) PC - PC+4 + (sign-extend)immediate2bne000101rsrtimmediatebne$1,$2,10if($1!=$2)gotoPC+4+40if (rs != rt) PC - PC+4 + (sign-extend)immediate2slti001010rsrtimmediateslti $1,$2,10if($210)$1=1else$1=0if (rs (sign-extend)immediate) rt=1elsert=0 ; 其中rs$2,rt=$1sltiu001011rsrtimmediatesltiu $1,$2,10if($210)$1=1else$1=0if (rs (zero-extend)immediate) rt=1elsert=0 ; 其中rs$2,rt=$1J-typeopaddressj000010addressj10000goto10000PC - (PC+4)31.28,address,0,0;address=10000/4jal000011addressjal10000$31-PC+4;goto10000$31-PC+4;PC - (PC+4)31.28,address,0,0;address=10000/4更全的MIPS匯編指令Arithmetic 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位立即數(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, 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.and 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 the 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, src1, src2 # Right shift arithmetic.srl des, src1, src2 # Right shift logical.sllv des, src1, src2 # $t0 = $t1 $t3,shift right logicalsrav des, src1, src2 # $t0 = $t1 $t3,shift right arithm.Comparison Instructionsseq des, 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) des, src1, src2 # des 1 if src1 = 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 = 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, then put the address of the next instruction# into $ra and branch to lab.bgtzal src1, lab # If src1 0, 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 the 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 + 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 (possibly unaligned) address addr into des.ulw des, addr # Load the word starting at the (possibly unaligned) address addr into des.sb src1, addr # Store the lower byte of register src1 to addr.sh src1, addr # Store the lower halfword of register src1 to addr.sw src1, addr # Store the word in register src1 to addr.swl src1, addr # Stor
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 交換合同范本
- 二零二五年度城市綠化測繪合同十景觀規(guī)劃3篇
- 二零二四南通單位勞動合同試用期考核與轉(zhuǎn)正協(xié)議3篇
- 二零二四年裝修包清工合同范本:售后服務與保修條款3篇
- 個性化定制廣告推廣服務合同范本2024版B版
- 2025年度個人藝術品修復服務合同范本2篇
- 二零二五年度商業(yè)地產(chǎn)項目場地租賃與物業(yè)管理合同4篇
- 個人寵物店運營租賃合同(2024版)3篇
- 投資包賠合同模版
- 二零二五年度鄉(xiāng)村旅游池塘使用權轉(zhuǎn)讓合同范本4篇
- 張家界喀斯特地貌
- 讓學生看見你的愛
- 12123交管學法減分練習題及答案二(帶圖文通用版)
- 銷售禮盒營銷方案
- 南潯至臨安公路(南潯至練市段)公路工程環(huán)境影響報告
- 《小英雄雨來》讀書分享會
- 初中數(shù)學校本教材(完整版)
- 重慶市銅梁區(qū)2024屆數(shù)學八上期末檢測試題含解析
- 中央導管相關血流感染防控
- 光的偏振和晶體光學基礎課件
- 中科大光學講義08光的偏振
評論
0/150
提交評論