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

  • O Praise the Name (Anástasis)

    O Praise the Name (Anástasis)

    O Praise the Name (Anástasis) I cast my mind to Calvary Where Jesus bled and died for me. I see His wounds, His hands, His feet. My Savior on that cursed tree His body bound and drenched in tears They...
  • The Influences of a Local Coal-Fired Ambient Mercury ...

    The Influences of a Local Coal-Fired Ambient Mercury ...

    Acknowledgement. Undergraduate students at UNR. Matthew Peckham, Douglas Yan, Travis Lyman, MushengAlishahi, and Jennifer Arnold. The site operators
  • Chapter 3 Effects of IT on Strategy and Competition

    Chapter 3 Effects of IT on Strategy and Competition

    Mission statement: is about where and what they portray today. ... Students who disagree with this statement might argue that even the capability of the IT organization is not a sustainable advantage because people come and go, they can be...
  • Fourth Brigade JROTC - Fourth Bde JROTC

    Fourth Brigade JROTC - Fourth Bde JROTC

    Both you and school official must sign Scan the signed 2767 and save (preferably PDF file) Use the browse and submit buttons to upload and submit the scanned document for validation Cert. Document (DD Form 2754) Before the submission process...
  • Neurological Disorders - University of Kentucky

    Neurological Disorders - University of Kentucky

    Brain Damage Traumatic brain injury Strokes Alzheimer's Disease Parkinson's Disease Other neurological disorders discussed in the book will NOT be subject to test questions Traumatic Brain Injury FACTS: 1.4 million who sustain a TBI each year in the United States...
  • Odysseus' Homecoming

    Odysseus' Homecoming

    -A topic sentence that provides a claim or idea you are making about the relevance of The Odyssey-Evidence from the poem to support your ideas (at least 2 quotes)-Commentary and analysis of your evidence (2-3 sentences per quote)-A concluding sentence...
  • CS 478 - Machine Learning

    CS 478 - Machine Learning

    Perceptron Neural Networks Sub-symbolic approach: Does not use symbols to denote objects Views intelligence/learning as arising from the collective behavior of a large number of simple, interacting components Motivated by biological plausibility (i.e., brain-like) Natural Neuron Artificial Neuron Captures the...
  • The CAPM

    The CAPM

    The Capital Asset Pricing Model Ming Liu Industrial Engineering and Management Sciences, Northwestern University Winter 2009 * * * * * * Returns to financial securities P0: security price at time 0 P1: security price at time 1 DIV1: dividend...