EEC4133 Computer Organization & Architecture Chapter 6: Languages and the Machine by Muhazam...

Preview:

Citation preview

EEC4133Computer Organization &

ArchitectureChapter 6: Languages and the Machine

by Muhazam Mustapha, May 2014

Learning Outcome

• By the end of this chapter, students are expected to have some theoretical concept of how high performance assembly coding is done

Most of the material in this slide set is adopted from Murdocca & Heuring 2007

Chapter Content

• Process of Generating Machine Code– Compile, Assemble, Link, Load– Macro

• High Performance Computing– Pipelining– Overlapping Register– Low Power Coding

Generating Machine Code

Compilation

• [Definition] Compilation is a process of converting high level language code into assembly language code

• The high level languages include: C, C++, C#, Java, Pascal, BASIC, etc

• These high level languages are machine (microprocessor) independent

Compilation

• Example (a C language code):– a = b+c;– This code may convert to:

MOV A, [b];ADD A, [c];MOV [a], A;

Assembly

• [Definition] Assembly is a process of converting assembly language instructions into machine language opcode that consist of 1-s and 0-s

• Assembly language instruction and its corresponding machine language opcode is highly dependent to the microprocessor being used

Assembly

• Example:– MOV A, B;– This assembly code may convert to machine

code:

1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

Op

Addressing Type

Target Source

Macro

• [Definition] Macro is a piece of assembly code that is invoked like a subroutine but actually is expanded inline into the program during preprocessing before assembly

• Having macros in assembly language program while avoid overhead of subroutine calls (faster runtime), but the resulting machine code will be larger

Macro

Linking

• [Definition] Linking is a process after assembly to resolve (finalize) the resources pointer or location that have been defined in separate modules either in libraries or user defined

• After linking, all off module or clashing parameters will be resolved to the correct references

Loading

• A finished executable code will references within itself or external locations

• External references most likely is fixed

• Internal references will need to be adjusted as the code won’t have prior knowledge about the exact location where it is put in during execution

Loading

• [Definition] Loading is a process to load an executable into main memory and re-calculate the references to reflect the actual resources location at runtime

High Performance Computing

Pipelining

• In the fetch-execute cycle, one would realize that there is no need to wait for one instruction to complete the entire cycle before beginning the next one

Pipelining

• [Definition] Pipelining is an enhancement to the fetch-execute cycle, whereby a subsequent instruction can begin a stage in the cycle when the previous instruction is at the next stage, without waiting for that previous instruction to finish the entire cycle

Pipelining

Pipelining

• Obviously pipelining can be smoothly done if the sequence of instructions are properly synchronized and do not depend on the result of the earlier ones before they complete the cycle

• The logic to automatically re-arrange the instructions so that pipelining is at its optimum level is done by the compiler– Sometimes forced delay might be needed

Pipelining

Overlapping Register Use

• With pipelining, a further improvement can be made if the microprocessor has a large no. registers that can be set to input registers and output registers

• [Definition] Overlapping register use is the use input registers by a second procedure call, while the first procedure call has NOT yet returned, but already finished using those input registers

Overlapping Register Use

Low Power Coding

• Consider the following code:ld [2096], %r16ld [2100], %r17ld [2104], %r18ld [2108], %r19

• The corresponding machine code is:

2

Low Power Coding

• The no. transitions in the previous code is 8, and can be reduced to 6 if they are re-arranged:

Low Power Coding

• With less transitions in the machine code there will be less power used

• This can be achieved by Gray code sequencing of instruction code

• This is just one way to power optimized our machine code

Recommended