Unformatted text preview:

1Sparc ArchitectureCS217CourseOutline• FirstfourweeksCprogramming• SecondfourweeksMachinearchitecture• ThirdfourweeksUnixoperatingsystem2CompilationPipeline• Compiler(gcc):.c  .s– translateshigh-levellanguagetoassemblylanguage• Assembler(as):.s  .o– translatesassemblylanguagetomachinelanguage• Archiver(ar):.o  .a– collectsobjectfilesintoasinglelibrary• Linker(ld):.o + .a  a.out– buildsanexecutablefilefromacollectionofobjectfiles• Execution(execlp)– loadsanexecutablefileintomemoryandstartsitExampleCompilation• High-levellanguagex=a+b;• Assemblylanguagelda,%r1ldb,%r2add%r1,%r2,%r3st %r3,x• Machinelanguage110000100000...SymbolicRepresentationBit-encodedRepresentation3MachineArchitectureControlUnitCacheRegistersALUFPUCPUMemoryDisk Net DisplayMBusI/OBusStorageHierarchy• Registers~128,1-5nsaccesstime(CPUcycletime)• Cache1KB– 4MB,20-100ns(multiplelevels)• Memory64MB– 2GB,200ns• Disk1GB– 100GB,10ms• Long-termStorage1TB,1-10s4Outline• Instructionexecution• Accessingregisters• Accessingmemory• Instructionformats• etc.InstructionExecution• CPU’scontrolunitexecutesaprogramPC memorylocationoffirstinstructionwhile(PC!=last_instr_addr)execute(MEM[PC]);• Multiplephases…fetch: instructionfetch;incrementPCdecode: interpretinstructionformatoperandfetch: loadoperandsintoregistersexecute: performinstructionopcodestore: writeresultstomemory5InstructionPipelining• Pipeline• PC isincrementedby4attheFetch stagetoretrievethenextinstruction...Fetch Decode Oprnd Execute StoreFetch Decode Oprnd Execute StoreFetch Decode Oprnd Execute StoreSparcRegisters• 32x 32-bitgeneral-purposeregisters%r0…%r31• Registermap%g0…%g7%r0…%r7 global%o0…%o7%r8…%r15 output%l0…%l7%r16…%r23 local%i0…%i7%r24…%r31 input• Someregistershavededicateduses%sp(%r14,%o6) stackpointer%fp (%r30,%i6) framepointer%r15 temporary%r31 returnaddress%g0(%r0) always 06SparcRegisters(cont)• Special-purposeregistersmanipulatedbyspecialinstructions• Examplesfloatingpointregisters(%f0…%f31)programcounter (PC)nextprogramcounter (NPC)integercodition codes (PSR)trapbaseregister (TBR)window (WIM)etc.Instructions• Eachmachineinstructioniscomposedof…opcode: operationtobeperformedoperand: datathatisoperatedupon• Eachmachinesupportsafewformats…opcodeopcodedstopcodesrcdstopcode src1src2dst7SparcInstructionSet• Instructiongroupsintegerarithmetic(add,sub,...)bit-wiselogical(and,or,xor,...)bit-wiseshift(sll,srl,...)load/store(ld, st,...)integerbranch(be,bne,bl,bg,...)Trap(ta,te,...)controltransfer(call,save,...)floatingpoint(ldf,stf,fadds,fsubs,...)floatingpointbranch(fbe,fbne,fbl,fbg,...)SparcInstructionSet• InstructionformatsFormat1(op=1)-- e.g.,callFormat2(op=0):-- e.g.,branchesFormat3(op=2or3):-- e.g.,addop31 298Sparc InstructionSet• Format3(op=2or 3):31 29 24 18 13 12 4oprd op3 rs1 ignore0 rs2add%i1,%i2,%o2Sparc InstructionSet• Format3(op=2or 3):31 29 24 18oprd op3 rs1 simm1313112 4oprd op3 rs1 ignore0 rs2ORsimm13isasignedconstantwithin+-4096add%i1,360,%o29Example• AssemblyLanguageadd%i1,360,%o2• Machinelanguage1001010000000110011000010110100031 29 24 18212 0 31 55013112210 0 25 3601(decimal)(octal)Other Sparc Instructions• Format1(op=1)-- e.g.,call• Format2 (op=0)-- e.g.,branchesop disp3031 29oprd op2 imm22opa cond op2 disp2231 29 28 24 2110AddressingMemory• 8-bitbyteisthesmallestaddressableunit• 32-bitaddresses;thus32-bitaddressspace• Canloadandstoredoublewords too• Sparc isbig-endianAA A+1 A+2 A+3A A+17 01531bytehalfwordwordAddressingMemory• Twomodestoyieldeffectiveaddressaddcontentsoftworegistersld[%o1],%o2registerindirectst %o1,[%o2+%o3]registerindexedaddcontentsofregisterandimmediateld[%o1+10],%o2basedisplacement11UpcomingLectures...• Instructionset• Numbersystems• Branchingconditioncodes• Procedurecalls• Assembler• Linker•


View Full Document

Princeton COS 217 - Sparc architecture

Documents in this Course
Summary

Summary

4 pages

Lecture

Lecture

4 pages

Generics

Generics

14 pages

Generics

Generics

16 pages

Lecture

Lecture

20 pages

Debugging

Debugging

35 pages

Types

Types

7 pages

Lecture

Lecture

21 pages

Assembler

Assembler

16 pages

Lecture

Lecture

20 pages

Lecture

Lecture

39 pages

Testing

Testing

44 pages

Pipeline

Pipeline

19 pages

Lecture

Lecture

6 pages

Signals

Signals

67 pages

Building

Building

17 pages

Lecture

Lecture

7 pages

Modules

Modules

12 pages

Generics

Generics

16 pages

Testing

Testing

22 pages

Signals

Signals

34 pages

Lecture

Lecture

19 pages

Load more
Download Sparc architecture
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Sparc architecture and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Sparc architecture 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?