SLAU132Y September 2004 – June 2021
The compiler tools include a feature that interlists C/C++ source statements into the assembly language output of the compiler. The interlist feature enables you to inspect the assembly code generated for each C statement. The interlist behaves differently, depending on whether or not the optimizer is used, and depending on which options you specify.
The easiest way to invoke the interlist feature is to use the --c_src_interlist option. To compile and run the interlist on a program called function.c, enter:
cl430 --c_src_interlist function
The --c_src_interlist option prevents the compiler from deleting the interlisted assembly language output file. The output assembly file, function.asm, is assembled normally.
When you invoke the interlist feature without the optimizer, the interlist runs as a separate pass between the code generator and the assembler. It reads both the assembly and C/C++ source files, merges them, and writes the C/C++ statements into the assembly file as comments.
For information about using the interlist feature with the optimizer, see Section 4.12. Using the --c_src_interlist option can cause performance and/or code size degradation.
The following example shows a typical interlisted assembly file.
;******************************************************************************
.compiler_opts --mem_model:code=flat --mem_model:data=flat --symdebug:none
; acp430 -@/var/tmp/TI764/AAAv0aGVG
.sect ".text"
.align 2
.clink
.global main
;-----------------------------------------------------------------------
; 3 | int main()
;-----------------------------------------------------------------------
;******************************************************************************
;* FUNCTION NAME: main *
;* *
;* Regs Modified : SP,SR,r11,r12,r13,r14,r15 *
;* Regs Used : SP,SR,r11,r12,r13,r14,r15 *
;* Local Frame Size : 2 Args + 0 Auto + 0 Save = 2 byte *
;******************************************************************************
main:
;* ---------------------------------------------------------------------------*
SUB.W #2,SP
;-----------------------------------------------------------------------
; 5 | printf("Hello, world\n");
;-----------------------------------------------------------------------
MOV.W #$C$SL1+0,0(SP) ; |5|
CALL #printf ; |5|
; |5|
;-----------------------------------------------------------------------
; 7 | return 0;
;-----------------------------------------------------------------------
MOV.W #0,r12 ; |7|
ADD.W #2,SP ; |7|
RET ; |7|
; |7|
;******************************************************************************
;* STRINGS *
;******************************************************************************
.sect ".const"
.align 2
$C$SL1: .string "Hello, world",10,0
;******************************************************************************
;* UNDEFINED EXTERNAL REFERENCES *
;******************************************************************************
.global printf