1 / 29

ECSE436 Tutorial

ECSE436 Tutorial. Assembly and Linear Assembly Laurier Boulianne. Questions. Outline. Introduction to Assembly Linear Assembly AMR Reading. TMS320 Assemby Language. C6000 ISA. Instruction Packing. Sample Instructions. Sample Instruction. Instruction List. Instruction List.

lisbet
Download Presentation

ECSE436 Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECSE436 Tutorial Assembly and Linear Assembly Laurier Boulianne

  2. Questions

  3. Outline • Introduction to Assembly • Linear Assembly • AMR • Reading

  4. TMS320AssembyLanguage

  5. C6000 ISA

  6. Instruction Packing

  7. Sample Instructions

  8. Sample Instruction

  9. Instruction List

  10. Instruction List

  11. C program calling and ASM function

  12. C program calling and ASM function -Values passed to the assembly functions using registers : A4,B4,A6,B6 and so on -Only registers A1,A2,B0,B1,B2 can be used as conditional registers -B3 contain the return address -A4 is the return value -Need to take into account the NOP

  13. Linear Assembly • To effectively program a DSP using assembly language, you need to do the scheduling by hand! • Need to account for the number of clock cycles each functional unit takes, etc… • Difficult, so TI has linear assembly • you don’t have to schedule it, the compiler does it for you • can use CPU resources without worrying about scheduling, register allocation, etc…

  14. What is Linear Assembly ? Enables you write assembly-like programs Do not have to worry about : • Registerusage • Pipelining • Delay slots • etc.

  15. What is Linear Assembly ? C code TI Linear Assembly Efficiency Ease of use Assembly

  16. What is Linear Assembly ? It is a cross between C and Assembly It lets you : • use symbolic names • forget pipeline issues • ignore putting NOPs • parallel bars • functional units • register names • more efficiently use CPU resources than C

  17. Linear Assembly Extension in c is .c Extension in linear assembly is .sa

  18. Example Dot Product From Chassaing //DOTPclasm.c short dotp4clasmfunc(short *a, short *b, short ncount); #include <stdio.h> #define count 4 short x[count] = {0,1,2,3}; short y[count] = {100, -20, 30, -20}; volatile int result = 0; main() { result = dotp4clasmfunc(x,y,count); printf("result = %d decimal \n", result); } Function written in LASM

  19. Example Dot Product From Chassaing The LASM code .def _dotp4clasmfunc _dotp4clasmfunc: .cproc ap, bp, count .reg a, b, prod, sum zero sum loop: ldh *ap++,a ldh *bp++,b mpy a,b,prod add prod,sum,sum sub count,1,count [count] b loop .return sum .endproc

  20. Example Dot Product From Chassaing Define and ASM function called from C .def _dotp4clasmfunc Name of the function Start a section of Linear assembly _dotp4clasmfunc: .cproc ap, bp, count Arguments of the function Set up your variables (similar to C) .reg a, b, prod, sum

  21. Example Dot Product From Chassaing Initialize your sum to zero zero sum Load the value from memory pointed by ap, copy it to register a and increment the pointer by 1 ldh *ap++,a ldh stands for load half word (a short in C) Do the same thing with b ldh *bp++,b

  22. Example Dot Product From Chassaing Multiply a and b and write the result to prod mpy a,b,prod Add sum and prod and write the result to sum add prod,sum,sum Decrement count by 1 sub count,1,count

  23. Example Dot Product From Chassaing If count is different than 0, branch to loop [count] b loop Return sum as the output of your function (exactly Like the return command in C) .return sum End linear assembly function .endproc

  24. Circular Addressing

  25. AMR Addressing mode register Read Chassaing at pages : 82-83

  26. AMR Addressing mode register

  27. AMR Addressing mode register How to modify the AMR ? MVKL .S2 0x0004,B2 MVKH .S2 0x0005,B2 MVC .S2 B2,AMR MVC is the only function which can modify the content of a control register Be sure to reset the AMR at the end of your function Also, do the same inside your interrupt routine, check SPRU 187 to know how to modify the AMR from C There is a good example on how AMR works in SPRU189 at page 97-98

  28. For more Information Read Chaissaing at pages : 87-88 and 112-115 Read Kuo and Gan at pages : 243-245 Read TMS320C6000 Optimizing Compiler User's Guide: Chapter 4(SPRU187) It contains the description of the directives (.trip, .cprog, .reg, etc.) Read TMS320C6000 CPU and Instruction Set Reference Guide (SPRU189) It contains the description of the instruction set (add, mpy, sub, mv, etc.)

  29. Questions ?

More Related