Radford ITEC 352 - Languages and the Machines

Unformatted text preview:

Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 5: Languages and the MachineChapter ContentsThe Compilation ProcessSlide 4The Assembly ProcessAssembly ExampleInstruc-tion For-mats and PSR Format for the ARCAssembled CodeForward ReferencingSlide 10Assembled ProgramLinking: Using .global and .externLinking and Loading: Symbol TablesExample ARC ProgramMacro DefinitionRecursive Macro ExpansionIntel MMX (MultiMedia eXtensions)Intel and Motorola Vector RegistersMMX and AltiVec Arithmetic InstructionsComparing Two MMX Byte Vectors for EqualityConditional Assignment of an MMX Byte VectorAddressing ModesSubroutine Linkage – RegistersSubroutine Linkage – Data Link AreaSubroutine Linkage – StackStack Linkage ExampleStack Linkage Example (cont’)Slide 28Slide 29Touchscreen I/O DeviceFlowchart for I/O DeviceJava Virtual Machine ArchitectureJava Pro-gram and Com-piled Class FileA Java Class FileA Java Class File (Cont’)Byte Code for Java Program5-1Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationPrinciples of Computer ArchitectureMiles Murdocca and Vincent HeuringChapter 5: Languages and the Machine5-2Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationChapter Contents5.1 The Compilation Process5.2 The Assembly Process5.3 Linking and Loading5.4 Macros5.5 Case Study: Extensions to the Instruction Set – The Intel MMX™ and Motorola AltiVec™ SIMD Instructions5-3Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationThe Compilation Process• Compilation translates a program written in a high level language into a functionally equivalent program in assembly language.• Consider a simple high-level language assignment statement:A = B + 4;• Steps involved in compiling this statement into assemby code:— Reducing the program text to the basic symbols of the language (for example, into identifiers such as A and B), denotations such as the constant value 4, and program delimiters such as = and +. This portion of compilation is referred to as lexical analysis.— Parsing symbols to recognize the underlying program structure. For the statement above, the parser must recognize the form:Identifier “=” Expression,where Expression is further parsed into the form: Identifier “+” Constant.Parsing is sometimes called syntactic analysis.5-4Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationThe Compilation Process— Name analysis: associating the names A and B with particular program variables, and further associating them with particular memory locations where the variables are located at run time.— Type analysis: determining the types of all data items. In the example above, variables A and B and constant 4 would be recognized as being of type int in some languages. Name and type analysis are sometimes referred to together as semantic analysis: determining the underlying meaning of program components.— Action mapping and code generation: associating program statements with their appropriate assembly language sequence. In the statement above, the assembly language sequence might be as follows:ld [B], %r0, %r1 ! Get variable B into a register.add %r1, 4, %r2 ! Compute the value of the expressionst %r2, %r0, [A] ! Make the assignment.5-5Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationThe Assembly Process• The process of translating an assembly language program into a machine language program is referred to as the assembly process.• Production assemblers generally provide this support:— Allow programmer to specify locations of data and code.— Provide assembly-language mnemonics for all machine instructions and addressing modes, and translate valid assembly language statements into the equivalent machine language.— Permit symbolic labels to represent addresses and constants.— Provide a means for the programmer to specify the starting address of the program, if there is one; and provide a degree of assemble-time arithmetic.— Include a mechanism that allows variables to be defined in one assembly language program and used in another, separately assembled program.— Support macro expansion.5-6Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationAssembly Example• We explore how the assembly process proceeds by “hand assembling” a simple ARC assembly language program.5-7Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationInstruc-tionFor-mats and PSR Format for the ARC5-8Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationAssembled Codeld [x], %r1 1100 0010 0000 0000 0010 1000 0001 0100ld [y], %r2 1100 0100 0000 0000 0010 1000 0001 1000addcc %r1,%r2,%r3 1000 0110 1000 0000 0100 0000 0000 0010st %r3, [z] 1100 0110 0010 0000 0010 1000 0001 1100jmpl %r15+4, %r0 1000 0001 1100 0011 1110 0000 0000 010015 0000 0000 0000 0000 0000 0000 0000 11119 0000 0000 0000 0000 0000 0000 0000 10010 0000 0000 0000 0000 0000 0000 0000 00005-9Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationForward Referencing• An example of forward referencing:5-10Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer Organization5-11Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationAssembled Program5-12Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationLinking: Using .global and .extern• A .global is used in the module where a symbol is defined and a .extern is used in every other module that refers to it.5-13Chapter 5 - Languages and the MachineDepartment of Information Technology, Radford University ITEC 352 Computer OrganizationLinking and Loading: Symbol Tables• Symbol


View Full Document

Radford ITEC 352 - Languages and the Machines

Download Languages and the Machines
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 Languages and the Machines 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 Languages and the Machines 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?