QtSpim Tutorial

Preview:

DESCRIPTION

Assembly language

Citation preview

  • QtSpimTutorialContents

    1. Installation2. Usage3. Overview4. FirstProgram

    Installation

    WewillbeusingSPIM,aMIPSsimulator,inordertolearnassemblyprogramming.ThecurrentversionofSPIMis"QtSPIM",akaSPIMusingtheQtcrossplatformapplicationGUIframework:

    InstalltheQtframeworkthatSPIMrequires:

    unix>sudoaptgetinstallqt4devtoolsqt4doclibqt4help

    DownloadaprepackagedversionofSPIMforLinuxthatusestheQtGUIframework:(Ifyouarerunninganolder32bitLinuxinstallation,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.

    http://qt.nokia.com/http://qt.nokia.com/http://spimsimulator.sourceforge.net/

  • Therearethreeprimarysectionscontainedwithinthiswindow:TheRegisterpanel,Memorypanel,andMessagespanel.

    RegisterPanel

    TheRegisterpanel(shownbelow)showsthecontentsofalltheMIPSregisters.Therearetwotabsinthispanel:oneforthefloatingpointregistersandonefortheintegerregisters.Theintegerregistersincludegeneralpurposeregisters(R1R31),alongwithspecialpurposeregisterssuchastheProgramCounter(PC).

  • MemoryPanel

    TheMemorypanelhastwotabs:DataandText.TheTexttabshowsthecontentsoftheProgrammemoryspace.Fromlefttoright,thisincludes:

    1. Thememoryaddressofaninstructioninhexadecimal(showninbrackets)2. Thecontentsofthatmemoryaddressinhexadecimal.Inbinaryform,thisistheactualMIPS

    instructionthattheprocessorruns!3. The"humanreadable"assemblylanguageinstructionusingthehardwareregisternumbers

    (showninbold).4. Theassemblylanguageprogramyouwroteusingsymbolicregisternamesandmemory

    addresssymbols(showninitalics)

  • TheDatatabshowsthecontentsoftheDatamemoryspace.Thisincludesthevariablesandarraydatayoucreate,alongwiththestackcontent.

  • MessagesPanel

    TheMessagespaneldisplaysmessagesfromQtSPIMtotheuser.

    FirstProgram

    AvarietyofMIPSexampleprogramsareavailabletoyou.Startwiththefirstprogramexample1.asmbydownloadingittoyourcomputer.

    LoadyourfirstprogrambyselectingFile>ReinitializeandLoadFile.(RecallthatthenewUbuntu"Unity"GUIdoesn'tshowthetopofscreenmenubaruntilyoumouseoverit).Thisclearstheregisterspaceandresetsthesimulator.(Otherwise,youcouldloadandrunseveralprogramsinarowonthesamemachinestate.)

    YoucanscrolldownintheTextpanetoseethattheassemblycodehasbeenloadedintoProgrammemoryspace.Inthiscase,thefirstinstructionisatmemorylocation0x00400024.(Whydoesn'titstartatmemoryaddresszero?Theprogramstartswiththefunctionmain(),butthereissomecode

    http://ecs-network.serv.pacific.edu/ecpe-170/tutorials/example1.asm/viewhttp://ecs-network.serv.pacific.edu/ecpe-170/tutorials/mips-example-programs

  • thatrunsbeforemain).

    Nowthattheprogramhasbeenloaded,youcanrunasimulationoftheassemblyinstructions.Youhavethreechoices:

    1. Runtheprogramfrombeginningtoend(viathe"play"Run/ContinuebuttonorF5).Thisisusefulforseeingthefinaloutputoftheprogram.

    2. Stepthroughtheprogramonelineatatime(viathe"123"SingleStepbuttonorF10).Thisisusefultoseehoweachassemblyinstructionaffectsthemachinestate(i.e.memoryandregistervalues).

    3. Runtheprogramuntilyoureachabreakpoint(whichcanbesetbyrightclickingonanylineintheMemorypanel.

    Stepthroughthecompleteprogram,figureoutwhatitdoes,andmakesureyouunderstandhowtheQtSPIMenvironmentworks.

Recommended