This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PRU C/C++ Codegen PC v2.1.0 incorrect code generated

In line 69 of the compiler listing below, the wrong address register is used, should be R14, I think.

Kind regards

Anthony Hailes

SOURCE CODE---------------------------------------------------------------------------

static int staticVar = 0;

int Func()
{
int localVar;

localVar = 1 + staticVar;

return localVar;
}

COMPILER OUTPUT-------------------------------------------------------------------

PRU Assembler PC v2.1.0 Mon Dec 22 16:25:37 2014

Tools Copyright (c) 2012-2014 Texas Instruments Incorporated
C:\Users\TONY~1.HAI\AppData\Local\Temp\0746410 PAGE 1

1;******************************************************************************
2;* PRU C/C++ Codegen PC v2.1.0 *
3;* Date/Time created: Mon Dec 22 16:25:37 2014 *
4;******************************************************************************
5 .compiler_opts --abi=eabi --diag_wrap=off --endian=little --hll_source=on --object_format=elf
6
7$C$DW$CU .dwtag DW_TAG_compile_unit
8 .dwattr $C$DW$CU, DW_AT_name("../bug.c")
9 .dwattr $C$DW$CU, DW_AT_producer("TI PRU C/C++ Codegen PC v2.1.0 Copyright (c) 2012-2014 Texas
10 .dwattr $C$DW$CU, DW_AT_TI_version(0x01)
11 .dwattr $C$DW$CU, DW_AT_comp_dir("")
12 00000000 .data
13 .align 1
14 .elfsym ||staticVar||,SYM_SIZE(4)
15 00000000 ||staticVar||:
16 00000000 00000000000000 .bits 0,32 ; staticVar @ 0
17
18$C$DW$1 .dwtag DW_TAG_variable, DW_AT_name("staticVar")
19 .dwattr $C$DW$1, DW_AT_TI_symbol_name("staticVar")
20 .dwattr $C$DW$1, DW_AT_type(*$C$DW$T$10)
21 .dwattr $C$DW$1, DW_AT_location[DW_OP_addr ||staticVar||]
22 .dwattr $C$DW$1, DW_AT_decl_file("../bug.c")
23 .dwattr $C$DW$1, DW_AT_decl_line(0x08)
24 .dwattr $C$DW$1, DW_AT_decl_column(0x0c)
25; c:\ti\ccsv6\tools\compiler\ti-cgt-pru_2.1.0\bin\acpiapru.exe -@C:\\Users\\TONY~1.HAI\\AppData\
26 00000000 .sect ".text:Func"
27 .clink
28 .global ||Func||
29
30$C$DW$2 .dwtag DW_TAG_subprogram, DW_AT_name("Func")
31 .dwattr $C$DW$2, DW_AT_low_pc(||Func||)
32 .dwattr $C$DW$2, DW_AT_high_pc(0x00)
33 .dwattr $C$DW$2, DW_AT_TI_symbol_name("Func")
34 .dwattr $C$DW$2, DW_AT_external
35 .dwattr $C$DW$2, DW_AT_type(*$C$DW$T$10)
36 .dwattr $C$DW$2, DW_AT_TI_begin_file("../bug.c")
37 .dwattr $C$DW$2, DW_AT_TI_begin_line(0x0a)
38 .dwattr $C$DW$2, DW_AT_TI_begin_column(0x05)
39 .dwattr $C$DW$2, DW_AT_decl_file("../bug.c")
40 .dwattr $C$DW$2, DW_AT_decl_line(0x0a)
41 .dwattr $C$DW$2, DW_AT_decl_column(0x05)
42 .dwattr $C$DW$2, DW_AT_TI_max_frame_size(0x04)
43 .dwpsn file "../bug.c",line 11,column 1,is_stmt,address ||Func||,isa 0
44
45 .dwfde $C$DW$CIE, ||Func||
46
47;***************************************************************
48;* FNAME: Func FR SIZE: 4 *
49;* *
50;* FUNCTION ENVIRONMENT *
51;* *
52;* FUNCTION PROPERTIES *
53;* 4 Auto, 0 SOE *
54;***************************************************************
55
PRU Assembler PC v2.1.0 Mon Dec 22 16:25:37 2014

Tools Copyright (c) 2012-2014 Texas Instruments Incorporated
C:\Users\TONY~1.HAI\AppData\Local\Temp\0746410 PAGE 2

56 00000000 ||Func||:
57;* --------------------------------------------------------------------------*
58 .dwcfi cfa_offset, 0
59 00000000 0000000504E2E2 SUB r2, r2, 0x04 ; []
60 .dwcfi cfa_offset, 4
61$C$DW$3 .dwtag DW_TAG_variable, DW_AT_name("localVar")
62 .dwattr $C$DW$3, DW_AT_TI_symbol_name("localVar")
63 .dwattr $C$DW$3, DW_AT_type(*$C$DW$T$10)
64 .dwattr $C$DW$3, DW_AT_location[DW_OP_breg8 0]
65 .dwpsn file "../bug.c",line 14,column 2,is_stmt,isa 0
66 00000004 000000240000E0! LDI r0, ||staticVar|| ; [] |14| staticVar


67 00000008 000000F1002080 LBBO &r0, r0, 0, 4 ; [] |14|

68 0000000c 0000000101E0E0 ADD r0, r0, 0x01 ; [] |14|


69 00000010 000000E1002280 SBBO &r0, r2, 0, 4 ; [] |14| localVar


70 .dwpsn file "../bug.c",line 16,column 2,is_stmt,isa 0
71 00000014 000000F100228E LBBO &r14, r2, 0, 4 ; [] |16| localVar
72 .dwpsn file "../bug.c",line 17,column 1,is_stmt,isa 0
73 00000018 0000000104E2E2 ADD r2, r2, 0x04 ; []
74 .dwcfi cfa_offset, 0
75$C$DW$4 .dwtag DW_TAG_TI_branch
76 .dwattr $C$DW$4, DW_AT_low_pc(0x00)
77 .dwattr $C$DW$4, DW_AT_TI_return
78 0000001c 00000020C30000 JMP r3.w2 ; []
79 .dwattr $C$DW$2, DW_AT_TI_end_file("../bug.c")
80 .dwattr $C$DW$2, DW_AT_TI_end_line(0x11)
81 .dwattr $C$DW$2, DW_AT_TI_end_column(0x01)
82 .dwendentry
83 .dwendtag $C$DW$2
84
85