A computer that plays cards - University of Iowa
Transcript of A computer that plays cards - University of Iowa
Acomputerthatplayscards1.Comeupwithabinaryencodingfora52-carddeck
SlideinspiredbyCSE351Spring2016
2.Wewantthefollowingoperationstobeeasytoimplement• Comparetwocards,whichishighervalue?• Comparetwocards,aretheythesamesuit?
Operationsonapairofcards
Ifyouarestilltryingtogetintotheclass• Considerusinganadd/dropformtosignupforECE3350ComputerArchitectureandOrganization• equivalenttoCS2630intermsofcontentandprogramrequirements/pre-requisites
CS2630ComputerOrganization
Meeting4:IntrotoArchitecture(specifically,MIPS)BrandonMyers
UniversityofIowa
Wherewearegoing
Instructionsetarchitecture(e.g.,MIPS)
Compiler
Memorysystem I/OsystemProcessor
Datapath &Control
Digitallogic
translatingsourcecode(CorJava)ProgramstoassemblylanguageAndlinkingyourcodetoLibrarycode
HowthesoftwaretalksTothehardware
HowaprocessorrunsMIPSPrograms!
Howswitches(1or0)canbeusedtobuildInterestingfunctions:fromintegerarithmetictoprogrammablecomputers
Wherewearegoing
Instructionmemory
Executionengine
Datamemory
NEXTwhatgetsstoredinhere
Learnedsomebitwiseoperations
Learnedhowbitsareorganizedinmemory
Wherewearegoing
Instructionsetarchitecture(e.g.,MIPS)
Compiler
Memorysystem I/OsystemProcessor
Datapath &Control
Digitallogic
translatingsourcecode(CorJava)ProgramstoassemblylanguageAndlinkingyourcodetoLibrarycode
HowthesoftwaretalksTothehardware
HowaprocessorrunsMIPSPrograms!
Howswitches(1or0)canbeusedtobuildInterestingfunctions:fromintegerarithmetictoprogrammablecomputers
Representationsofaprogram
Compiler
int x = arr[1];arr[2] = x + 10;
lw $t0, 4($r0)addi $t0, $t0, 10sw $t0, 8($r0)
Assembler
100011100000100000000000000001000010000100001000000000000000101010101110000010000000000000001000
Highlevellanguageprogram(humanreadable)
assemblyprogramastext(CS2630studentreadable)
assemblyprogramasbinary(machinereadable)
Languages• Highlevellanguage(HLL)programsareinstructionsetarchitecture-independent• languageisconvenienttouse• languageishaspowerfulfeatures
• Assemblylanguageprogramsarespecifictoaninstructionsetarchitecture• the“nativelanguage”oftheprocessor• languageisbare-bones:lacksmostofthefeaturesofHLLs
Java,C,Python,Lisp,C++,MATLAB,…
MIPS,ARM,x86,SPARC,Power,
Alpha,…
inthiscourse,theseareallsynonyms• Instructionsetarchitecture• instructionset• ISA• architecture
BriefhistoryofcompatibilitybeforeIBM360– differentarchitectureforeveryprocessor
postIBM360– onearchitectureforallprocessors
Processormodel1slowprocessor,small
memory
Processormodel2mediocreprocessor,mediummemory
Processormodel3fastprocessor,large
memory
my_program.asmversion1
my_program.asmversion2
my_program.asmversion3
my_program.asm
Processor1slowprocessor,small
memory
Processor2mediocreprocessor,mediummemory
Processor3fastprocessor,large
memory
PeerinstructionIwrotemyprograminC(ahighlevellanguage)andcompiledittorunonaMIPSmachine.WhatshouldIdotogetthatprogramtorunonanx86machine?
a) rewritemyCprogramtobecompatiblewithx86b) rewritemyprograminx86assemblylanguagec) recompilemyCprogramforx86d) reassemblemyprogramusingthex86assembler
Languages• Highlevellanguage:usuallyhasvariables,objects,andarrays
• Assemblylanguage:usuallyjusthasregisters andmemory
Themainidea• 4categoriesofinstructions• performanoperationontworegistersandstoreresultinaregister• performanoperationononeregisterandaconstantandstoretheresultinaregister• moveavaluebetweenaregisterandmemory• determinewhichinstructiontoexecutenext
0x0000
r0 <- M[address]
M[address] <- r0
r1 <- r0 + constant
r2 <- r1 + r0Registertransferlanguage• 4categoriesofinstructions• performanoperationontworegistersandstoreresultinaregister• performanoperationononeregisterandaconstantandstoretheresultinaregister• moveavaluebetweenaregisterandmemory• determinewhichinstructiontoexecutenext
(later!)
Exampleassemblyprogram
0-14501
address0x00x40x80xC
r0
r1
r2
MEMORYREGISTERS
a = x + y - z
axyz
highlevel Peerinstruction:Writeanassemblyprogramusingasequenceofinstructions(useregistertransferlanguage)