Linear Assembly Considerations
8-48
8.3.1.1
Function Calls and ADDKPC in Linear Assembly
The ’C64x provides a new instruction, ADDKPC , which is designed to reduce
codesize when making function calls. This new instruction is not directly ac-
cessible from Linear Assembly. However, Linear Assembly provides the func-
tion call directive, .call, and this directive makes use of ADDKPC. The .call di-
rective is explained in detail in the
TMS320C6000 Optimizing C/C++ Compiler
User’s Guide.
Example 8–22 illustrates a simple use of the .call directive. The Assembly Op-
timizer issues an ADDKPC as part of the function call sequence for this .call,
as shown in the compiler output in Example 8–23.
Example 8–22. Using the .call Directive in Linear Assembly
.data
hello .string ”Hello World”, 0
.text
.global _puts
.global _main
_main .cproc
.reg pointer
loop:
MVKL hello, pointer ; Generate a 32–bit pointer to the
MVKH hello, pointer ; phrase ”Hello World”.
.call _puts(pointer) ; Print the string ”Hello World”.
B loop ; Keep printing it.
.endproc
Example 8–23. Compiler Output Using ADDKPC
loop:
; .call _puts(pointer) ; Print the string ”Hello World”.
B .S1 _puts ; |15|
MVKL .S1 hello,A4 ; |12| Generate a 32–bit pointer to the
ADDKPC .S2 RL0,B3,2 ; |15|
MVKH .S1 hello,A4 ; |13| phrase ”Hello World”.
RL0: ; CALL OCCURS ; |15|