欢迎来到天天文库
浏览记录
ID:52986928
大小:269.75 KB
页数:28页
时间:2020-04-08
《mips快速入门-入门指南-简单高效.pptx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Mips快速入门ProgramStructurejustplaintextfilewithdatadeclarations,programcode(nameoffileshouldendinsuffix.stobeusedwithSPIMsimulator)datadeclarationsectionprogramcodesectionDataDeclarationsplacedinsectionofprogramidentifiedwithassemblerdirective.datadeclaresvariablena
2、mesusedinprogram;storageallocatedinmainmemory(RAM)Codeplacedinsectionoftextidentifiedwithassemblerdirective.textcontainsprogramcode(instructions)startingpointforcodee.g.ecutiongivenlabelmain:endingpointofmaincodeshoulduseexitsystemcall(seebelowunderSystemCalls)Com
3、mentsanythingfollowing#onaline#ThisstuffwouldbeconsideredacommentTemplateforaMIPSassemblylanguageprogram:#Commentgivingnameofprogramanddescriptionoffunction#Template.s#Bare-bonesoutlineofMIPSassemblylanguageprogram.data#variabledeclarationsfollowthisline#....text
4、#instructionsfollowthislinemain:#indicatesstartofcode(firstinstructiontoexecute)#...#Endofprogram,leaveablanklineafterwardstomakeSPIMhappyDataDeclarationsformatfordeclarations:name:storage_typevalue(s)createstorageforvariableofspecifiedtypewithgivennameandspecifie
5、dvaluevalue(s)usuallygivesinitialvalue(s);forstoragetype.space,givesnumberofspacestobeallocatedNote:labelsalwaysfollowedbycolon(:)examplevar1:.word3#createasingleintegervariablewithinitialvalue3array1:.byte'a','b'#createa2-elementcharacterarraywithelements#initial
6、izedtoaandbarray2:.space40#allocate40consecutivebytes,withstorageuninitialized#couldbeusedasa40-elementcharacterarray,ora#10-elementintegerarray;acommentshouldindicatewhich!Load/StoreInstructionsRAMaccessonlyallowedwithloadandstoreinstructionsallotherinstructionsu
7、seregisteroperandsload:lwregister_destination,RAM_source#copyword(4bytes)atsourceRAMlocationtodestinationregister.Lbregister_destination,RAM_source#copybyteatsourceRAMlocationtolow-orderbyteofdestinationregister,#andsign-e.g.tendtohigher-orderbytesstoreword:swreg
8、ister_source,RAM_destination#storewordinsourceregisterintoRAMdestinationsbregister_source,RAM_destination#storebyte(low-order)insourceregisterintoRAMdes
此文档下载收益归作者所有