Chapter 7 Linear Assembly

Slides:



Advertisements
Similar presentations
Chapter 7 Linear Assembly
Advertisements

Chapter 11 Interfacing C and Assembly Code
Introduction to C Programming
Spring Semester 2013 Lecture 5
4.
The University of Adelaide, School of Computer Science
Lecture 9: MIPS Instruction Set
TMS320C6713 Assembly Language (cont’d). Module 1 Exam (solution) 1. Functional Units a. How many can perform an ADD? Name them. a. How many can perform.
Lecture 6 Programming the TMS320C6x Family of DSPs.
Superscalar and VLIW Architectures Miodrag Bolic CEG3151.
Assembly and Linear Assembly Evgeny Kirshin, 05/10/2011
Review What is a virtual function? What can be achieved with virtual functions? How to define a pure virtual function? What is an abstract class? Can a.
Computer Architecture Lecture 7 Compiler Considerations and Optimizations.
TMS320C6000 Architectural and Programming Overview.
1 Lecture: Static ILP Topics: compiler scheduling, loop unrolling, software pipelining (Sections C.5, 3.2)
SPARC Architecture & Assembly Language
COMP3221 lec08-arith.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 8: C/Assembler Data Processing
Chapter 17 Goertzel Algorithm Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 2 Learning Objectives  Introduction.
Chapter 11 Interfacing C and Assembly Code. Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 11, Slide 2 Learning Objectives 
Guide To UNIX Using Linux Third Edition
Chapter 7 Linear Assembly. Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 7, Slide 2 Learning Objectives  Comparison of programming.
ICS312 Set 11 Introduction to Subroutines. All the combinations in which a subroutine can be written 1. The subroutine may be: a. Internal or b. External.
Macro & Function. Function consumes more time When a function is called, the copy of the arguments are passed to the parameters in the function. After.
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 l Array Basics l Arrays in Classes and Methods l Programming with Arrays.
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Purpose  This training module provides an overview of optimization techniques used in.
Computer architecture Lecture 11: Reduced Instruction Set Computers Piotr Bilski.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM511.
Learners Support Publications Functions in C++
Assembly Language for x86 Processors 7th Edition Chapter 13: High-Level Language Interface (c) Pearson Education, All rights reserved. You may modify.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 12P. 1Winter Quarter User-Written Functions Lecture 12.
1 One Dimensional Arrays Chapter 11 2 "All students to receive arrays!" reports Dr. Austin. Declaring arrays scores :
1 CSC2100B Data Structure Tutorial 1 Online Judge and C.
Functions Structured Programming. Topics to be covered Introduction to Functions Defining a function Calling a function Arguments, local variables and.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
A First Book of ANSI C Fourth Edition
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
ECSE436 Tutorial Assembly and Linear Assembly Laurier Boulianne.
Procedures Procedures are very important for writing reusable and maintainable code in assembly and high-level languages. How are they implemented? Application.
Invitation to Computer Science 6th Edition
User-Written Functions
Introduction to C++ Systems Programming.
Outline of the Chapter Basic Idea Outline of Control Flow Testing
MACRO Processors CSCI/CMPE 3334 David Egle.
A Play Core Timer Interrupts
Topics Introduction to File Input and Output
Chap. 8 :: Subroutines and Control Abstraction
Chap. 8 :: Subroutines and Control Abstraction
Chapter 14 - Advanced C Topics
Chapter 17 Goertzel Algorithm
Chapter 11 Interfacing C and Assembly Code
STUDY AND IMPLEMENTATION
The University of Adelaide, School of Computer Science
by Richard P. Paul, 2nd edition, 2000.
Logical and Decision Operations
A Play Lab. 2 Task 8 Core Timer Interrupts
Getting serious about “going fast” on the TigerSHARC
Midterm 2 review Chapter
Chapter 12 Software Optimisation
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Superscalar and VLIW Architectures
Chapter 12 Pipelining and RISC
The structure of programming
ECE 103 Engineering Programming Chapter 18 Iteration
Topics Introduction to File Input and Output
Lecture 5: Pipeline Wrap-up, Static ILP
EE 345S Real-Time Digital Signal Processing Lab Spring 2009
Chapter 15 Infinite Impulse Response (IIR) Filters
Introduction to Classes and Objects
Presentation transcript:

Chapter 7 Linear Assembly

Learning Objectives Comparison of programming techniques. How to write Linear Assembly. Interfacing Linear Assembly with C. Assembly optimiser tool.

Introduction With the assembly optimiser, optimisation for loops can be made very simple. Linear assembly takes care of the pipeline structure and generates highly parallel assembly code automatically. The performance of the assembly optimiser can easily reach the performance of hand written assembly code.

Comparison of Programming Techniques Source Efficiency* Effort 100% High ASM Hand Optimised 95 - 100% Linear ASM Med Assembly Optimiser 80 - 100% C C ++ Low Optimising Compiler * Typical efficiency vs. hand optimized assembly.

Writing in Linear Assembly Linear assembly is similar to hand assembly, except: Does not require NOPs to fill empty delay slots. The functions units do not need to be specified. Grouping of instructions in parallel is performed automatically. Accepts symbolic variable names. ZERO sum loop LDH *p_to_a, a LDH *p_to_b, b MPY a, b, prod ADD sum, prod, sum SUB B0, 1, B0 B loop

How to Write Code in Linear Assembly File extension: Use the “.sa” extension to specify the file is written in linear assembly. How to write code: _sa_Function .cproc ZERO sum loop LDH *pm++, m LDH *pn++, n MPY m, n, prod ADD sum, prod, sum [count] SUB count, 1, count B loop .return sum .endproc .cproc defines the beginning of the code NO NOPs required NO parallel instructions required NO functional units specified NO registers required .return specifies the return value .endproc defines the end of the linear assembly code

Passing and Returning Arguments “pm” and “pn” are two pointers declared in the C code that calls the linear assembly function. The following function prototype in C calls the linear assembly function: int y = dotp (short* a, short* x, int count) The linear assembly function receives the arguments using .cproc: _dotp .cproc pm, pn, count ... .return y .endproc

Declaring the Symbolic Variables All the symbolic registers except those used as arguments are declared as follows: .reg pm, pn, m, n, prod, sum The assembly optimiser will attempt to assign all these values to registers.

Complete Linear Assembly Code _dotp .cproc pm, pn, count .reg m, n, prod, sum ZERO sum loop LDH *pm++, m LDH *pn++, n MPY m, n, prod ADD sum, prod, sum [count] SUB count, 1, count B loop .return sum .endproc Note: Linear assembly performs automatic return to the calling function.

Function calls in Linear Assembly In linear assembly you can call other functions written in C, linear assembly or assembly. To do this the .call directive is used: Function1.sa _function1 .cproc a, b .reg y, float1 MPY a,b,y .call float1 = _fix_to_float(y) .return .endproc Fix_to_float.sa _fix_to_float .cproc fix .reg float1 INTSP fix, float1 .return float1 .endproc Note: Branch out of a linear assembly routine is not allowed.

Invoking the Assembly Optimiser The development tools recognise the linear assembler code by the file extension “.sa”. The assembly optimiser uses the same options as the optimising C compiler. Note: In CCS you can change the options of each file individually by right clicking on the file in the project view and selecting “File Specific Options…”.

Linear Assembly Examples The following chapters have code written in linear assembly: \Code\Chapter 15 - Infinite Impulse Response Filters \Code\Chapter 17 - Goertzel Algorithm For more details on Interfacing C and Assembly see Chapter 11.

Chapter 7 Linear Assembly - End -