Chapter 7 - Linear Assembly

Chapter 7 Linear Assembly Learning Objectives hapter 7, Slide 2 Comparison of programming techniques. How to write Linear Assembly. Interfacing Linear Assembly with C. Assembly optimiser tool. Dr. Nai Introduction hapter 7, Slide 3

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. Dr. Nai Comparison of Programming Techniques Source Efficiency* Effort ASM Hand Optimised 100% High Linear ASM Assembly

Optimiser 95 - 100% Med C C ++ Optimising Compiler 80 - 100% Low * Typical efficiency vs. hand optimized assembly. hapter 7, Slide 4 Dr. Nai Writing in Linear Assembly hapter 7, Slide 5

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. loop ZERO LDH LDH MPY ADD SUB B sum *p_to_a, a *p_to_b, b a, b, prod

sum, prod, sum B0, 1, B0 loop Dr. Nai 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 loop hapter 7, Slide 6 [count]

.cproc defines the beginning of the code .cproc ZERO sum LDH LDH MPY ADD SUB B *pm++, m *pn++, n m, n, prod sum, prod, sum count, 1, count loop .return sum .endproc 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 Dr. Nai 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) hapter 7, Slide 7 The linear assembly function receives the

arguments using .cproc: _dotp .cproc pm, pn, count ... .return y .endproc Dr. Nai Declaring the Symbolic Variables All the symbolic registers except those used as arguments are declared as follows: .reg hapter 7, Slide 8 pm, pn, m, n, prod, sum The assembly optimiser will attempt to assign all these values to registers.

Dr. Nai Complete Linear Assembly Code _dotp loop [count] .cproc pm, pn, count .reg m, n, prod, sum ZERO sum LDH LDH MPY ADD SUB B *pm++, m *pn++, n m, n, prod

sum, prod, sum count, 1, count loop .return sum .endproc hapter 7, Slide 9 Note: Linear assembly performs automatic return to the calling function. Dr. Nai 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 Fix_to_float.sa

_function1 _fix_to_float hapter 7, Slide 10 .cproc a, b .reg y, float1 .cproc fix .reg float1 MPY a,b,y INTSP fix, float1 .call float1 = _fix_to_float(y) .return .endproc .return float1 .endproc

Note: Branch out of a linear assembly routine is not allowed. Dr. Nai Invoking the Assembly Optimiser hapter 7, Slide 11 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. Dr. Nai

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

Recently Viewed Presentations

  • Interest Groups and Public Policy - National Chung Cheng ...

    Interest Groups and Public Policy - National Chung Cheng ...

    Stigler-Peltzman model. The state has a unique source: the power to coerce. Four. policies that a group may seek of the government (1) direct subsidy of money (2)entry barriers (3)substitutes and complements ... Interest Groups and Public Policy
  • AntaresInauguration

    AntaresInauguration

    …a selected overview... New Neutrino Detectors for Astro and Particle Physics...a "Bright" Future L. R. Sulak CPPM Marseille and Boston University
  • Section 4-4 - Hollidaysburg Area School District

    Section 4-4 - Hollidaysburg Area School District

    Section 4.4 Unstable Nuclei and Radioactive Decay. Explain. the relationship between unstable nuclei and radioactive decay. element: a pure substance that cannot be broken down into simpler substances by physical or chemical means. Characterize. alpha, beta, and gamma radiation in...
  • Energy & Power

    Energy & Power

    Example: NH. 3 This Lewis structure does NOT show the molecular shape. It DOES show the four electron groups. Lone pair is one of the four electron groups around the central atom. 4 Electron Groups. Electron pair geometry: Tetrahedral ....
  • Tracking Data Changes - SQLSaturday

    Tracking Data Changes - SQLSaturday

    The tools available natively in Microsoft SQL Server to track data changes have gotten better and better over time. With SQL 2016 SP1 most if not all these tools are available to everyone with a SQL standard license or better....
  • Connected Learning Week 5 CL environment map feedback

    Connected Learning Week 5 CL environment map feedback

    Part B: Critical discussion of the connected learning environment. Critically discuss the connected learning environment that you mapped (in Part A).
  • Moodle at UMass Amherst

    Moodle at UMass Amherst

    Due to scheduled maintenance by Turnitin, Turnitin services will be unavailable on Saturday, January 4th, EST 11:00 AM to 5:00 PM.During this maintenance window, users will not be able to submit or grade.
  • Clinical Pharmacokinetics of Immune Therapeutics

    Clinical Pharmacokinetics of Immune Therapeutics

    Evaluations: i.e. PharmAcademic, RxPreceptor. Incorporating Learner Feedback. Two learners at same level on rotation together. Incorporating dues dates in rotation activities list. Meetings. Include short description for each meeting including attendees and objectives.