RISC, CISC, and Assemblers!Hakim&Weatherspoon&CS&3410,&Spring&2011&Computer)Science)Cornell)University)See)P&H)Appendix)B.1<2,))and)Chapters)2.8)and)2.12))2)Announcements!PA1)due)this)Friday))Work)in)pairs)Use)your)resources)• FAQ,)class)notes,)book,)SecGons,)office)hours,)newsgroup,)CSUGLab))Prelims1:)next)Thursday,)March)10th)in)class)• Material)covered)• Appendix)C)(logic,)gates,)FSMs,)memory,)ALUs)))• Chapter)4)(pipelined)[and)non<pipeline])MIPS)processor)with)hazards))• Chapters)2)and)Appendix)B)(RISC/CISC,)MIPS,)and)calling)convenGons))• Chapter)1)(Performance))• HW1,)HW2,)PA1,)PA2)• PracGce)prelims)are)online)in)CMS)• Closed)Book:)cannot)use)electronic)device)or)outside)material)• We)will)start)at)1:25pm)sharp,)so)come)early)))3)Goals for Today!InstrucGon)Set)Architetures)• Arguments:)stack<based,)accumulator,)2<arg,)3<arg)• Operand)types:)load<store,)memory,)mixed,)stacks,)…)• Complexity:)CISC,)RISC)Assemblers)• assembly)instrucGons)• psuedo<instrucGons)• data)and)layout)direcGves)• executable)programs)4)Instruction Set Architecture!ISA)defines)the)permissible)instrucGons)• MIPS:)load/store,)arithmeGc,)control)flow,)…)• ARM:)similar)to)MIPS,)but)more)shia,)memory,)&)condiGonal)ops)• VAX:)arithmeGc)on)memory)or)registers,)strings,)polynomial)evaluaGon,)stacks/queues,)…)• Cray:)vector)operaGons,)…)• x86:)a)lifle)of)everything)5)One Instruction Set Architecture!Toy)example:)subleq)a,)b,)target))Mem[b])=)Mem[b])–)Mem[a])then)if)(Mem[b])<=)0))goto)target)else)conGnue)with)next)instrucGon)clear)a)==)subleq)a,)a,)pc+4)jmp)c)==)subleq)Z,)Z,)c)add)a,)b)==)subleq)a,)Z,)pc+4;))) )subleq)Z,)b,)pc+4;))) )subleq)Z,)Z,)pc+4)6)PDP-8!Not<a<toy)example:)PDP<8))One)register:)AC))Eight)basic)instrucGons:)) )AND)a) )#)AC)=)AC)&)MEM[a])) )TAD)a) )#)AC)=)AC)+)MEM[a])) )ISZ)a) )#)if)(!++MEM[a]))skip)next)) )DCA)a) )#)MEM[a])=)AC;)AC)=)0)) )JMS)a) )#)jump)to)subrouGne)(e.g.)jump)and)link))) )JMP)a) )#)jump)to)MEM[a])) )IOT)x )#)input/output)transfer)) )OPR)x) )#)misc)operaGons)on)AC)7)Stack Based!Stack)machine)• data)stack)in)memory,)stack(pointer)register)• Operands)popped/pushed)as)needed)add)[)Java)Bytecode,)PostScript,)odd)CPUs,)some)x86)])Tradeoffs:)8)Accumulator Based!Accumulator)machine)• Results)usually)put)in)dedicated)accumulator)register)add)b)store)b)[)Some)x86)])Tradeoffs:)))9)Load-Store!Load/store)(register<register))architecture)• computaGon)only)between)registers)[)MIPS,)some)x86)])Tradeoffs:)10)Axes!Axes:)• Arguments:)stack<based,)accumulator,)2<arg,)3<arg)• Operand)types:)load<store,)memory,)mixed,)stacks,)…)• Complexity:)CISC,)RISC))11)Complex Instruction Set Computers!People)programmed)in)assembly)and)machine)code!)• Needed)as)many)addressing)modes)as)possible)• Memory)was)(and)sGll)is))slow)CPUs)had)relaGvely)few)registers)• Register’s)were)more)“expensive”)than)external)mem)• Large)number)of)registers)requires)many)bits)to)index))Memories)were)small)• Encoraged)highly)encoded)microcodes)as)instrucGons)• Variable)length)instrucGons,)load/store,)condiGons,)etc)12)Reduced Instruction Set Computer!Dave)Paferson)• RISC)Project,)1982)• UC)Berkeley)• RISC<I:)½)transGsters)&)3x)faster)• Influences:)Sun)SPARC,)namesake)of)industry)John)L.)Hennessy)• MIPS,)1981)• Stanford)• Simple)pipelining,)keep)full)• Influences:)MIPS)computer)system,)PlayStaGon,)Nintendo)13)Complexity!MIPS)=)Reduced)InstrucGon)Set)Computer)(RlSC))• ≈)200)instrucGons,)32)bits)each,)3)formats)• all)operands)in)registers)– almost)all)are)32)bits)each)• ≈)1)addressing)mode:)Mem[reg)+)imm]))x86)=)Complex)InstrucGon)Set)Computer)(ClSC))• >)1000)instrucGons,)1)to)15)bytes)each)• operands)in)dedicated)registers,))general)purpose)registers,))memory,)on)stack,)…)– can)be)1,)2,)4,)8)bytes,)signed)or)unsigned)• 10s)of)addressing)modes)– e.g.))Mem[segment)+)reg)+)reg*scale)+)offset])14)RISC vs CISC!RISC)Philosophy)Regularity)&)simplicity)Leaner)means)faster)OpGmize)the))common)case)CISC)Rebufal)Compilers)can)be)smart)Transistors)are)plenGful)Legacy)is)important)Code)size)counts)Micro<code!))15)Goals for Today!InstrucGon)Set)Architetures)• Arguments:)stack<based,)accumulator,)2<arg,)3<arg)• Operand)types:)load<store,)memory,)mixed,)stacks,)…)• Complexity:)CISC,)RISC)Assemblers)• assembly)instrucGons)• psuedo<instrucGons)• data)and)layout)direcGves)• executable)programs)16)Examples!!...!T:!ADDI!r4,!r0,!,1!!BEQ!r3,!r0,!B!!ADDI!r4,!r4,!1!!LW!r3,!0(r3)!!J!T!!NOP!B:!...!!...!!JAL!L!!nop!!nop!L: !LW!r5,!0(r31)!!ADDI!r5,!r5,!1!!SW!r5,!!0(r31)!!...!17)cs3410 Recap/Quiz!17)int!x!=!10;!x!=!2!*!x!+!15;!C)compiler)addi!r5,!r0,!10!muli!r5,!r5,!2!addi!r5,!r5,!15!MIPS)assembly)00100000000001010000000000001010!00000000000001010010100001000000!00100000101001010000000000001111!machine)code)assembler)CPU))Circuits))Gates))Transistors))Silicon)18)Example 1!!...!T:!ADDI!r4,r0,,1!!BEQ!r3,!r0,!B!!ADDI!r4,r4,!1!!LW!r3,!0(r3)!!J!T!!NOP!B:!...!...)001000)000100)001000)100011)000010)00000000000000000000000000000000)...)19)References!Q:)How)to)resolve)labels)into)offsets)and)addresses?)A:)Two<pass)assembly)• 1st)pass:)lay)out)instrucGons)and)data,)and)build)a)symbol(table)(mapping)labels)to)addresses))as)you)go)• 2nd)pass:)encode)instrucGons)and)data)in)binary,)using)symbol)table)to)resolve)references))20)Example 2!!...!!JAL!L!!nop!!nop!L:!LW!r5,!0(r31)!!ADDI!r5,r5,1!!SW!r5,!0(r31)!!...!...)00100000000100000000000000000100))00000000000000000000000000000000)00000000000000000000000000000000)10001111111001010000000000000000)00100000101001010000000000000001)00000000000000000000000000000000)...)21)Example 2 (better)!.text!0x00400000!#!code!segment!!...!!ORI!r4,!r0,!counter!!LW!r5,!0(r4)!!ADDI!r5,!r5,!1!!SW!r5,!!0(r4)!!...!.data!0x10000000!#!data!segment!counter:!!!.word!0!22)Lessons!Lessons:)• Mixed)data)and)instrucGons)(von)Neumann)(• …)but)best)kept)in)separate)segments(• Specify)layout)and)data)using)assembler(direc4ves))•
View Full Document