欢迎来到天天文库
浏览记录
ID:38843125
大小:269.70 KB
页数:28页
时间:2019-06-20
《mips快速入门-入门指南-简单高效》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Mips快速入门ProgramStructurejustplaintextfilewithdatadeclarations,programcode(nameoffileshouldendinsuffix.stobeusedwithSPIMsimulator)datadeclarationsectionprogramcodesectionDataDeclarationsplacedinsectionofprogramidentifiedwithassemblerdirective.datadeclaresvariablenamesusedinprogram;storagea
2、llocatedinmainmemory(RAM)Codeplacedinsectionoftextidentifiedwithassemblerdirective.textcontainsprogramcode(instructions)startingpointforcodee.g.ecutiongivenlabelmain:endingpointofmaincodeshoulduseexitsystemcall(seebelowunderSystemCalls)Commentsanythingfollowing#onaline#Thisstuffwouldbeco
3、nsideredacommentTemplateforaMIPSassemblylanguageprogram:#Commentgivingnameofprogramanddescriptionoffunction#Template.s#Bare-bonesoutlineofMIPSassemblylanguageprogram.data#variabledeclarationsfollowthisline#....text#instructionsfollowthislinemain:#indicatesstartofcode(firstinstructiontoexe
4、cute)#...#Endofprogram,leaveablanklineafterwardstomakeSPIMhappyDataDeclarationsformatfordeclarations:name:storage_typevalue(s)createstorageforvariableofspecifiedtypewithgivennameandspecifiedvaluevalue(s)usuallygivesinitialvalue(s);forstoragetype.space,givesnumberofspacestobeallocatedNote:
5、labelsalwaysfollowedbycolon(:)examplevar1:.word3#createasingleintegervariablewithinitialvalue3array1:.byte'a','b'#createa2-elementcharacterarraywithelements#initializedtoaandbarray2:.space40#allocate40consecutivebytes,withstorageuninitialized#couldbeusedasa40-elementcharacterarray,ora#10-
6、elementintegerarray;acommentshouldindicatewhich!Load/StoreInstructionsRAMaccessonlyallowedwithloadandstoreinstructionsallotherinstructionsuseregisteroperandsload:lwregister_destination,RAM_source#copyword(4bytes)atsourceRAMlocationtodestinationregister.Lbregister_destination,RAM_source#co
7、pybyteatsourceRAMlocationtolow-orderbyteofdestinationregister,#andsign-e.g.tendtohigher-orderbytesstoreword:swregister_source,RAM_destination#storewordinsourceregisterintoRAMdestinationsbregister_source,RAM_destination#storebyte(low-order)insourceregisterintoRAMdes
此文档下载收益归作者所有