a computer that plays cards - university of iowa

18
A computer that plays cards 1. Come up with a binary encoding for a 52-card deck Slide inspired by CSE351 Spring 2016 2. We want the following operations to be easy to implement Compare two cards, which is higher value? Compare two cards, are they the same suit? Operations on a pair of cards

Upload: others

Post on 06-Jan-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

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

Memory

Registers

https://library.law.uiowa.edu/history-library

https://library.law.uiowa.edu/history-library

000000040008000C001000140018001C002000240028

memory registers

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)

Whattodonext• HW1/Quiz1duetonight• ReadingsuponarchitectureandMIPS• HW2/Quiz2upbytomorrow,dueFeb2• InstallMARSontheresourcespageofthewebsite,you’lluseitinHW2• WatchMARSvideos1&2ontheModulespage

• cometodebugyourbraintonight