Вы находитесь на странице: 1из 16

Seminar on TMS 320 C 6x:

S1 M Tech SP

Contents
Assembler Directives
Linear Assembly ASM Statement within C C Callable Assembly Function

College of Engg: Cherthala

ASSEMBLER DIRECTIVES

Message for the assembler, not an instruction Resolved during the assembling process. Does not produce executable code. Directives .text and .data indicate a section for
C oll eg e of E ng g: C he rth al a

text and data, respectively.

ASSEMBLER DIRECTIVES

CONT...

Other commonly used assembler directives are: 1) .short: to initialize a 16-bit integer. 2) .int: to initialize a 32-bit integer. 3) .float: to initialize a 32-bit IEEE singleprecision constant. 4) .double: to initialize a 64-bit IEEE doubleC oll eg e of E ng g: C he rth al a

precision constant.
4

LINEAR ASSEMBLY

Assembly like language written without parallel instructions, functional units etc.
Linear assembly code is a cross between assembly and C. Uses syntax same as assembly code, like ADD, SUB & MPY with operands same as in C.
5

C oll eg e of E ng g: C he rth al a

LINEAR ASSEMBLY CONT...

Uses assembler optimizer with linear assembly source program.


Assembler optimizer

assigns the functional unit and register to use . finds instructions that can execute in parallel . performs software pipelining.

C oll eg e of E ng g: C he rth al a

LINEAR ASSEMBLY CONT...

Optimizer produces assembly coded program. Assembly-coded program by the assembler optimizer is more efficient than from the C compiler optimizer. Linear assembly code should include the .cproc and .endproc directives.

C oll eg e of E ng g: C he rth al a

Delimit a section of code that we want the assembly optimizer to optimize


7

ASM STATEMENT WITHIN C

Assembly instructions can be incorporated within a C program using the asm statement The syntax is asm (assembly code); assembly code part has the same format as a valid assembly statement.
C oll eg e of E ng g: C he rth al a

ASM STATEMENT WITHIN C

CONT...

The compiler does not check it for syntax error but copies directly into the compiled output file. If the assembly statement has a syntax error, the assembler would detect it. The asm statement can provide access to hardware features.
C oll eg e of E ng g: C he rth al a

C-CALLABLE ASSEMBLY FUNCTION

Commonly C program includes some critical DSP functions written in assembly language. Improves the performance. Writing a C callable assembly function become common.
C oll eg e of E ng g: C he rth al a

A C-program calling an assembly function is illustrated as follows.


10

C-CALLABLE ASSEMBLY FUNCTION CONT...


Programming example.
Sum of n + (n - 1) + (n - 2) + . . . + 1, Using C Calling an Assembly Function.
C oll eg e of E ng g: C he rth al a

11

C-CALLABLE ASSEMBLY FUNCTION CONT...


Sumfunc.asm Assembly function to find n + (n-1) + ... + 1
C oll eg e of E ng g: C he rth al a

12

C-CALLABLE ASSEMBLY FUNCTION CONT...

The C source program sum.c calls the assemblycoded function sumfunc.asm.


The value of n set in the main C program is passed through register A4.

The value n in register A4 is moved to register A1.

C oll eg e of E ng g: C he rth al a

13

C-CALLABLE ASSEMBLY FUNCTION CONT...

A1 is set as a loop counter. The branch statement is conditional based on register A1. Loop section of code starts with the label or address and ends with the branch statement B.

C oll eg e of E ng g: C he rth al a

The resulting sum is accumulated in A4, which is passed to result in the C program.
14

REFERENCES

Digital Signal Processing and Applications with the C6713 and C6416 DSK By Rulph Chassaing
Texas instruments Application Report SPRA806 - December 2001

C oll eg e of E ng g: C he rth al a

15

THANK YOU
16

Co lle ge of En gg : Ch ert hal a

Вам также может понравиться