Académique Documents
Professionnel Documents
Culture Documents
Contents
1.
2.
3.
4.
Installation
Usage
Overview
FirstProgram
Installation
WewillbeusingSPIM,aMIPSsimulator,inordertolearnassemblyprogramming.Thecurrent
versionofSPIMis"QtSPIM",akaSPIMusingtheQtcrossplatformapplicationGUIframework:
InstalltheQtframeworkthatSPIMrequires:
unix>sudoaptgetinstallqt4devtoolsqt4doclibqt4help
DownloadaprepackagedversionofSPIMforLinuxthatusestheQtGUIframework:(Ifyouare
runninganolder32bitLinuxinstallation,change64to32below)
unix>wgethttp://sourceforge.net/projects/spimsimulator/files/qtspim_9.1.12_linux64.deb
InstalltheQtSPIMpackage:
unix>sudodpkgiqtspim_9.1.12_linux64.deb
Usage
TolaunchQtSPIM:
unix>qtspim&
Overview
AfterlaunchingQtSPIM,themainwindowshouldappearasshownbelow.
Therearethreeprimarysectionscontainedwithinthiswindow:TheRegisterpanel,Memorypanel,
andMessagespanel.
RegisterPanel
TheRegisterpanel(shownbelow)showsthecontentsofalltheMIPSregisters.Therearetwotabsin
thispanel:oneforthefloatingpointregistersandonefortheintegerregisters.Theintegerregisters
includegeneralpurposeregisters(R1R31),alongwithspecialpurposeregisterssuchasthe
ProgramCounter(PC).
MemoryPanel
TheMemorypanelhastwotabs:DataandText.TheTexttabshowsthecontentsoftheProgram
memoryspace.Fromlefttoright,thisincludes:
1. Thememoryaddressofaninstructioninhexadecimal(showninbrackets)
2. Thecontentsofthatmemoryaddressinhexadecimal.Inbinaryform,thisistheactualMIPS
instructionthattheprocessorruns!
3. The"humanreadable"assemblylanguageinstructionusingthehardwareregisternumbers
(showninbold).
4. Theassemblylanguageprogramyouwroteusingsymbolicregisternamesandmemory
addresssymbols(showninitalics)
TheDatatabshowsthecontentsoftheDatamemoryspace.Thisincludesthevariablesandarray
datayoucreate,alongwiththestackcontent.
MessagesPanel
TheMessagespaneldisplaysmessagesfromQtSPIMtotheuser.
FirstProgram
AvarietyofMIPSexampleprogramsareavailabletoyou.Startwiththefirstprogram
example1.asmbydownloadingittoyourcomputer.
LoadyourfirstprogrambyselectingFile>ReinitializeandLoadFile.(RecallthatthenewUbuntu
"Unity"GUIdoesn'tshowthetopofscreenmenubaruntilyoumouseoverit).Thisclearstheregister
spaceandresetsthesimulator.(Otherwise,youcouldloadandrunseveralprogramsinarowonthe
samemachinestate.)
YoucanscrolldownintheTextpanetoseethattheassemblycodehasbeenloadedintoProgram
memoryspace.Inthiscase,thefirstinstructionisatmemorylocation0x00400024.(Whydoesn'tit
startatmemoryaddresszero?Theprogramstartswiththefunctionmain(),butthereissomecode
thatrunsbeforemain).
Nowthattheprogramhasbeenloaded,youcanrunasimulationoftheassemblyinstructions.You
havethreechoices:
1. Runtheprogramfrombeginningtoend(viathe"play"Run/ContinuebuttonorF5).Thisisuseful
forseeingthefinaloutputoftheprogram.
2. Stepthroughtheprogramonelineatatime(viathe"123"SingleStepbuttonorF10).Thisis
usefultoseehoweachassemblyinstructionaffectsthemachinestate(i.e.memoryandregister
values).
3. Runtheprogramuntilyoureachabreakpoint(whichcanbesetbyrightclickingonanylinein
theMemorypanel.
Stepthroughthecompleteprogram,figureoutwhatitdoes,andmakesureyouunderstandhowthe
QtSPIMenvironmentworks.