mips and basic assembly language - github pages– optionally, through a program called qtspim (gui...
TRANSCRIPT
![Page 1: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/1.jpg)
MIPSandBasicAssemblyLanguage
CS64:ComputerOrganizationandDesignLogicLecture#4
ZiadMatni
Dept.ofComputerScience,UCSB
![Page 2: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/2.jpg)
4/12/18 Matni,CS64,Sp18 2
ThisWeekon
“DidjaKnowDat?!”
![Page 3: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/3.jpg)
4/12/18 Matni,CS64,Sp18 3
WhydoCPUprogrammerscelebrateChristmasandHalloween
onthesameday?
BecauseOct-31=Dec-25
![Page 4: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/4.jpg)
LectureOutline
• MIPScoreprocessingblocks
• Basicprogramminginassembly
• Arithmeticprograms
• Controllogicprograms
4/12/18 Matni,CS64,Sp18 4
![Page 5: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/5.jpg)
AnyQuestionsFromLastLecture?
4/12/18 Matni,CS64,Sp18 5
![Page 6: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/6.jpg)
4/12/18 Matni,CS64,Sp18 6
MIPS
![Page 7: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/7.jpg)
WhyMIPS?• MIPS:
– areducedinstructionsetcomputer(RISC)architecturedevelopedbyMIPSTechnologies(1981)
• Relevantintheembeddedsystemsdomain– Computersystemswithadedicatedfunctionwithinalarger
mechanicalorelectricalsystem– Example:lowpowerandlowcostprocessorsinMP3playersor
“Smart”Appliances
• AllmoderncommercialprocessorssharethesamecoreconceptsasMIPS,justwithextrastuff...butmoreimportantly...
4/12/18 Matni,CS64,Sp18 7
![Page 8: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/8.jpg)
MIPSisSimpler…
…thanotherinstructionsetsforCPUsSoit’sagreatlearningtool
• Dozensofinstructions(asopposedtohundreds)• Lackofredundantinstructionsorspecialcases• 5stagepipelineversus24stages
4/12/18 Matni,CS64,Sp18 8
![Page 9: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/9.jpg)
Note:PipelininginCPUs
4/12/18 Matni,CS64,Sp18 9
• PipeliningisafundamentaldesigninCPUs• Allowsmultipleinstructionstogoonatonce– a.k.ainstruction-levelparallelism
![Page 10: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/10.jpg)
CodeonMIPS
Originalx=5;y=7;z=x+y;
4/12/18 Matni,CS64,Sp18 10
MIPSli$t0,5li$t1,7add$t3,$t0,$t1
![Page 11: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/11.jpg)
CodeonMIPS
Originalx=5;y=7;z=x+y;
4/12/18 Matni,CS64,Sp18 11
MIPSli$t0,5li$t1,7add$t3,$t0,$t1loadimmediate:putthegivenvalueintoaregister$t0:temporaryregister0
![Page 12: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/12.jpg)
CodeonMIPS
Originalx=5;y=7;z=x+y;
4/12/18 Matni,CS64,Sp18 12
MIPSli$t0,5li$t1,7add$t3,$t0,$t1loadimmediate:putthegivenvalueintoaregister$t1:temporaryregister1
![Page 13: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/13.jpg)
CodeonMIPS
Originalx=5;y=7;z=x+y;
4/12/18 Matni,CS64,Sp18 13
MIPSli$t0,5li$t1,7add$t3,$t0,$t1add:addtherightmostregisters,puttingtheresultinthefirstregister$t3:temporaryregister3
![Page 14: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/14.jpg)
AvailableRegistersinMIPS
• 32registersinall– Refertoyour
MIPSReferenceCard
• Forthemoment,let’sonlyconsiderregisters$t0thru$t9
4/12/18 Matni,CS64,Sp18 14
![Page 15: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/15.jpg)
Assembly
• ThecodethatyouseeisMIPSassembly
• Assemblyis*almost*whatthemachinesees.Forthemostpart,itisadirecttranslationtobinaryfromhere(knownasmachinecode)
• Anassemblertakesassemblycodeandchangesitintotheactual1’sand0’sformachinecode– AnalogoustoacompilerforHLcode
4/12/18 Matni,CS64,Sp18 15
li$t0,5li$t1,7add$t3,$t0,$t1
![Page 16: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/16.jpg)
MachineCode/Language
• WhataCPUactuallyacceptsasinput• Whatactuallygetsexecuted
• Eachinstructionisrepresentedwith32bits
• Therearethreedifferentinstructionformats:R,I,andJ– Theseallowforinstructionstotakeondifferentroles– R-Formatisusedwhenit’sallaboutregisters– I-Formatisusedwhenyouinvolvenumbers– J-Formatisusedwhenyoudocode“jumping”(i.e.branching)
4/12/18 Matni,CS64,Sp18 16
![Page 17: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/17.jpg)
4/12/18 Matni,CS64,Sp18 17
Sinceallinstructionsare32-bits,thentheyeachoccupy4Bytesofmemory.
MemoryisaddressedinBytes(moreonthislater).
![Page 18: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/18.jpg)
4/12/18 Matni,CS64,Sp18 18
Sinceallinstructionsare32-bits,thentheyeachoccupy4Bytesofmemory.
MemoryisaddressedinBytes(moreonthislater).
![Page 19: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/19.jpg)
4/12/18 Matni,CS64,Sp18 19
Sinceallinstructionsare32-bits,thentheyeachoccupy4Bytesofmemory.
MemoryisaddressedinBytes(moreonthislater).
![Page 20: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/20.jpg)
4/12/18 Matni,CS64,Sp18 20
Sinceallinstructionsare32-bits,thentheyeachoccupy4Bytesofmemory.
MemoryisaddressedinBytes(moreonthislater).
![Page 21: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/21.jpg)
4/12/18 Matni,CS64,Sp18 21
Sinceallinstructionsare32-bits,thentheyeachoccupy4Bytesofmemory.
MemoryisaddressedinBytes(moreonthislater).
![Page 22: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/22.jpg)
4/12/18 Matni,CS64,Sp18 22
Sinceallinstructionsare32-bits,thentheyeachoccupy4Bytesofmemory.
MemoryisaddressedinBytes(moreonthislater).
![Page 23: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/23.jpg)
4/12/18 Matni,CS64,Sp18 23
Sinceallinstructionsare32-bits,thentheyeachoccupy4Bytesofmemory.
MemoryisaddressedinBytes(moreonthislater).
![Page 24: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/24.jpg)
4/12/18 Matni,CS64,Sp18 24
Sinceallinstructionsare32-bits,thentheyeachoccupy4Bytesofmemory.
MemoryisaddressedinBytes(moreonthislater).
![Page 25: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/25.jpg)
4/12/18 Matni,CS64,Sp18 25
Sinceallinstructionsare32-bits,thentheyeachoccupy4Bytesofmemory.
MemoryisaddressedinBytes(moreonthislater).
![Page 26: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/26.jpg)
4/12/18 Matni,CS64,Sp18 26
Sinceallinstructionsare32-bits,thentheyeachoccupy4Bytesofmemory.
MemoryisaddressedinBytes(moreonthislater).
![Page 27: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/27.jpg)
4/12/18 Matni,CS64,Sp18 27
Sinceallinstructionsare32-bits,thentheyeachoccupy4Bytesofmemory.
MemoryisaddressedinBytes(moreonthislater).
![Page 28: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/28.jpg)
AddingMoreFunctionality
• Whatabout:displayresults????Yes,that’skindaimportant…• Whatwouldthisentail?– EngagingwithInput/Outputpartofthecomputer– i.e.talkingtodevices
• Q:Whatusuallyhandlesthis?
• Soweneedawaytotell theoperatingsystemtokickin
4/12/18 Matni,CS64,Sp18 28
A:theoperatingsystem
![Page 29: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/29.jpg)
TalkingtotheOS
• WearegoingtoberunningonMIPSemulatorcalledSPIM– Optionally,throughaprogramcalledQtSPIM(GUIbased)– Whatisanemulator?
• We’renotactuallyrunningourcommandsonaMIPSprocessor!!!
…so,inotherwords…we’re“fakingit”
• Ok,sohowmightweprintsomethingontostd.out?
4/12/18 Matni,CS64,Sp18 29
![Page 30: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/30.jpg)
SPIMRoutines
• MIPSfeaturesasyscallinstruction,whichtriggersasoftwareinterrupt,orexception
• Outsideofanemulator(i.e.intherealworld),theseinstructionspausetheprogramandtelltheOStogodosomethingwithI/O
• Insidetheemulator,ittellstheemulatortogodosomethingwithI/O
4/12/18 Matni,CS64,Sp18 30
![Page 31: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/31.jpg)
syscall
• SowehavetheOS/emulator’sattention,buthowdoesitknowwhatwewant?
• TheOS/emulatorhasaccesstotheregisters
• Weputspecialvalues(codes)intheregisterstoindicatewhatwewant– Thesearecodesthatcan’tbeusedforanythingelse,so
they’reunderstoodtobejustforsyscall
4/12/18 Matni,CS64,Sp18 31
![Page 32: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/32.jpg)
ProgramFilesforMIPSAssembly
• Thefileshavetobetext
• Typicalfileextensiontypeis.asm
• Toleavecomments, use#atthestartoftheline
4/12/18 Matni,CS64,Sp18 32
![Page 33: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/33.jpg)
(Finally)PrintinganInteger• ForSPIM,ifregister$v0contains1andthenweissueasyscall,
thenSPIMwillprintwhateverintegerisstoredinregister$a0ßthisisaspecificruleusingaspecificcode– Note:$v0isusedforotherstuffaswell–moreonthatlater…– When$v0=1,syscallisexpectinganinteger!
• Othervaluesin$v0indicateothertypestosyscallExamples:– $v0=3meansdouble(orthememaddressofone)in$a0– $v0=4meansstring(orthememaddressofone)in$a0– We’llexploresomeoftheselater,butcheckMIPSrefcardforallofthem
4/12/18 Matni,CS64,Sp18 33
![Page 34: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/34.jpg)
(Finally)PrintinganInteger• Remember,theusualsyntaxtoloadimmediateavalueintoa
registeris: li<register>,<value>– Example: li$v0,1 #PUTSTHENUMBER1INTOREG.$v0
• Tomakesurethattheregister$a0hasthevalueofwhatyouwanttoprintout(let’ssayit’sinanotherregister),usethemovecommand:
move<toregister>,<fromregister>– Example: move$a0,$t0#PUTSTHEVALUEINREG.$t0INTOREG.$a0
4/12/18 Matni,CS64,Sp18 34
![Page 35: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/35.jpg)
4/12/18 Matni,CS64,Sp18 35
Ok…SoAboutThoseRegistersMIPShas32registers,each32bits
![Page 36: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/36.jpg)
AugmentingwithPrinting#Mainprogramli$t0,5li$t1,7add$t3,$t0,$t1#Printanintegertostd.outputli$v0,1move$a0,$t3syscall
4/12/18 Matni,CS64,Sp18 36
![Page 37: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/37.jpg)
We’reNotQuiteDoneYet!ExitinganAssemblyPrograminSPIM• IfyouareusingSPIM,thenyouneedtosaywhen
youaredoneaswell– MostHLLprogramsdothisforyouautomatically
• Howisthisdone?– Issueasyscallwithaspecialvaluein$v0=10(decimal)
4/12/18 Matni,CS64,Sp18 37
![Page 38: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/38.jpg)
AugmentingwithExiting#Mainprogramli$t0,5li$t1,7add$t3,$t0,$t1#Printtostd.outputli$v0,1move$a0,$t3syscall#Endprogramli$v0,10syscall
4/12/18 Matni,CS64,Sp18 38
![Page 39: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/39.jpg)
4/12/18 Matni,CS64,Sp18 39
MIPSSystemServicesExamplesWe’veSeenSoFar…
stdout
stdin
FileI/O
![Page 40: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/40.jpg)
NowLet’sMakeitaFullProgram(almost)
• Weneedtotelltheassembler(anditssimulator)whichbitsshouldbeplacedwhereinmemory– Bits?
(remember:everythingendsupbeingabunchof1’sand0’s!)
4/12/18 Matni,CS64,Sp18 40
AllocatedasprogramRUN
AllocatedatprogramLOAD
Constantstobeusedintheprogram(likestrings)
mutableglobalvariables
thetextoftheprogram
![Page 41: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/41.jpg)
MarkingtheCode
• Forthesimulator,you’llneeda.textdirectivetospecifycode
4/12/18 Matni,CS64,Sp18 41
AllocatedasprogramRUN
AllocatedatprogramLOAD
Constantstobeusedintheprogram(likestrings)
mutableglobalvariables
thetextoftheprogram
.text#Mainprogramli$t0,5li$t1,7add$t3,$t0,$t1#Printtostandardoutputli$v0,1move$a0,$t3syscall#Endprogramli$v0,10syscall
![Page 42: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/42.jpg)
Themoveinstruction
• ThemoveinstructiondoesnotactuallyshowupinSPIM
• Itisapseudo-instructionforustouse,butit’sactuallytranslatedintoanactualinstruction
ORIGINAL: move$a0,$t3ACTUAL: addu$a0,$zero,$t3 #what’saddu?what’s$zero?
4/12/18 Matni,CS64,Sp18 42
![Page 43: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/43.jpg)
WhyPseudocodes?Andwhat’sthis$zero??
• $zero– Specifiedlikeanormalregister,
butdoesnotbehavelikeanormalregister– Writesto$zeroarenotsaved– Readsfrom$zeroalwaysreturn0value
• Whyhavemoveasapseudo-instructioninsteadofasanactualinstruction?– It’sonelessinstructiontoworryabout– OnedesigngoalofRISCistocutoutredundancy– moveisn’ttheonlyone!liisanotheronetoo!
4/12/18 Matni,CS64,Sp18 43
![Page 44: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/44.jpg)
4/12/18 Matni,CS64,Sp18 44
ListofallCoreInstructionsinMIPS
![Page 45: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/45.jpg)
4/12/18 Matni,CS64,Sp18 45
ListoftheArithmeticCoreInstructionsinMIPS
![Page 46: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/46.jpg)
4/12/18 Matni,CS64,Sp18 46
ListofallPsuedoInstructionsinMIPSThatYouAreAllowedtoUseinCS64!!!
ALLOFTHISANDMOREISONYOURHANDY“MIPSREFERENCECARD”NOWFOUNDONTHECLASSWEBSITE
![Page 47: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/47.jpg)
MIPSPeculiarity:NORusedaNOT
• HowtomakeaNOTfunctionusingNORinstead• Recall:NOR=NOTOR• Truth-Table:
• So,intheabsenceofaNOTfunction, useaNORwitha0asoneoftheinputs!
4/12/18 Matni,CS64,Sp18 47
A B ANORB0 00 11 01 1
1
000
Notethat:0NORxx=NOTxx
![Page 48: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/48.jpg)
Let’sRunThisProgramAlready!UsingSPIM
• We’llcallitsimpleadd.asm• RunitonCSILas:$spim–fsimpleadd.asm
• We’llalsorunotherarithmeticprogramsandexplainthemaswegoalong– TAKENOTES!
4/12/18 Matni,CS64,Sp18 48
![Page 49: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/49.jpg)
YOURTO-DOs
• ReviewALLthedemocode– Availableviatheclasswebsite
• Assignment#1– DueFriday
• Assignment/Lab#2– LabonMONDAY– Submititviaturnin
4/12/18 Matni,CS64,Sp18 49
![Page 50: MIPS and Basic Assembly Language - GitHub Pages– Optionally, through a program called QtSPIM (GUI based) – What is an emulator? • We’re not actually running our commands on](https://reader033.vdocuments.mx/reader033/viewer/2022060322/5f0d93e17e708231d43b0c46/html5/thumbnails/50.jpg)
4/12/18 Matni,CS64,Sp18 50