AnsweredAssumed Answered

Register not saved on stack

Question asked by devver on May 14, 2019
Latest reply on May 23, 2019 by Edmar Wienskoski

Hi,

 

I'm having an issue with register r31 not being saved on stack. When I compile this code:

--------------------

#include "MPC5644A.h"

void HaltPeripherals(void) {
uint32_t i;

ETPU.ECR_A.B.FEND = 1;
for(i = 0; i < 32; i++) {
ETPU.CHAN[i].CR.B.CPR = 0;
}
ETPU.CISR_A.R = 0xFFFFFFFF;
ETPU.CIOSR_A.R = 0xFFFFFFFF;

PIT.TIMER[0].TCTRL.B.TEN = 0x0;
PIT.TIMER[1].TCTRL.B.TEN = 0x0;
PIT.TIMER[2].TCTRL.B.TEN = 0x0;
PIT.PITMCR.B.MDIS = 1;

ESCI_A.LCR.B.LIN = 0;
ESCI_A.CR2.B.MDIS = 1;
ESCI_B.LCR.B.LIN = 0;
ESCI_B.CR2.B.MDIS = 1;

ETPU.ECR_A.B.MDIS = 0;

CAN_A.MCR.B.MDIS = 0;
CAN_C.MCR.B.MDIS = 0;
for(i = 0; i < 364; i++) {
INTC.PSR[i].R = 0;
}
}

--------------------

It generates this code:

 

0: 18 21 06 f0 e_stwu r1,-16(r1)
4: 70 f8 e3 fc e_lis r7,50172
8: 1b c1 09 08 e_stmw r30,8(r1)
c: 48 14 se_li r4,1
e: c5 57 se_lwz r5,20(r7)
10: 48 06 se_li r6,0
12: 74 85 f8 00 e_rlwimi r5,r4,31,0,0
16: 48 04 se_li r4,0
18: d5 57 se_stw r5,20(r7)
1a: 4a 07 se_li r7,32
1c: 00 b7 se_mtctr r7
1e: 18 e6 80 40 e_addi r7,r6,64
22: 71 78 e3 fc e_lis r11,50172
26: 6c 47 se_slwi r7,4
28: 48 03 se_li r3,0
2a: 7c e7 5a 14 add r7,r7,r11
2e: 20 06 se_addi r6,1
30: c0 57 se_lwz r5,0(r7)
32: 74 85 e0 86 e_rlwimi r5,r4,28,2,3
36: d0 57 se_stw r5,0(r7)
38: 7a 20 ff e6 e_bdnz 1e <HaltPeripherals+0x1e>
3c: 70 f8 e3 ff e_lis r7,50175
40: 71 40 58 00 e_li r10,-327680
44: 2c 06 se_bmaski r6,0
46: 70 10 78 00 e_li r0,-32768
4a: 54 cb 02 00 e_stw r6,512(r11)
4e: 71 80 60 00 e_li r12,-262144
52: 54 cb 02 20 e_stw r6,544(r11)
56: 71 20 58 00 e_li r9,-327680
5a: 50 c7 01 08 e_lwz r6,264(r7)
5e: 19 29 d1 40 e_ori r9,r9,16384
62: 74 66 07 fe e_rlwimi r6,r3,0,31,31
66: 71 00 60 00 e_li r8,-262144
6a: 54 c7 01 08 e_stw r6,264(r7)
6e: 19 08 d1 80 e_ori r8,r8,32768
72: 53 e7 01 18 e_lwz r31,280(r7)
76: 70 9f e7 f4 e_lis r4,65524
7a: 74 7f 07 fe e_rlwimi r31,r3,0,31,31
7e: 48 1e se_li r30,1
80: 57 e7 01 18 e_stw r31,280(r7)
84: 48 06 se_li r6,0
86: 73 e0 01 6c e_li r31,364
8a: 65 04 se_bseti r4,16
8c: 00 bf se_mtctr r31
8e: 48 05 se_li r5,0
90: 53 e7 01 28 e_lwz r31,296(r7)
94: 74 7f 07 fe e_rlwimi r31,r3,0,31,31
98: 57 e7 01 28 e_stw r31,296(r7)
9c: c0 f7 se_lwz r31,0(r7)
9e: 77 df 0f bc e_rlwimi r31,r30,1,30,30
a2: d0 f7 se_stw r31,0(r7)
a4: 50 ea 00 0c e_lwz r7,12(r10)
a8: 74 67 c1 ce e_rlwimi r7,r3,24,7,7
ac: 54 ea 00 0c e_stw r7,12(r10)
b0: 58 ea 00 04 e_lhz r7,4(r10)
b4: 44 07 se_or r7,r0
b6: 5c ea 00 04 e_sth r7,4(r10)
ba: 50 e9 00 0c e_lwz r7,12(r9)
be: 74 67 c1 ce e_rlwimi r7,r3,24,7,7
c2: 54 e9 00 0c e_stw r7,12(r9)
c6: 58 e9 00 04 e_lhz r7,4(r9)
ca: 44 70 se_or r0,r7
cc: 5c 09 00 04 e_sth r0,4(r9)
d0: 50 eb 00 14 e_lwz r7,20(r11)
d4: 74 67 f0 42 e_rlwimi r7,r3,30,1,1
d8: 54 eb 00 14 e_stw r7,20(r11)
dc: 50 ec 00 00 e_lwz r7,0(r12)
e0: 74 67 f8 00 e_rlwimi r7,r3,31,0,0
e4: 54 ec 00 00 e_stw r7,0(r12)
e8: 50 e8 00 00 e_lwz r7,0(r8)
ec: 74 67 f8 00 e_rlwimi r7,r3,31,0,0
f0: 54 e8 00 00 e_stw r7,0(r8)
f4: 7c e4 32 14 add r7,r4,r6
f8: 20 06 se_addi r6,1
fa: 34 a7 00 40 e_stb r5,64(r7)
fe: 7a 20 ff f6 e_bdnz f4 <HaltPeripherals+0xf4>
102: 1b c1 08 08 e_lmw r30,8(r1)
106: 20 f1 se_addi r1,16
108: 00 04 se_blr

--------------------

 

The full command prompt I use to compile:

 

"C:/SysGCC/powerpc-eabi/bin/powerpc-eabivle-gcc.exe" -c -O2 -g3 -Wall -c -fmessage-length=0 -ffunction-sections -fdata-sections -mcpu=e200z3 -mbig -mvle -mregnames -mhard-float -meabi -Werror -specs="C:/SysGCC/powerpc-eabi/powerpc-eabivle/lib/e200z3/nosys.specs" -I"C:/SysGCC/powerpc-eabi/powerpc-eabivle/include" --sysroot="C:/SysGCC/powerpc-eabi/powerpc-eabivle/lib/e200z3/" -MMD -MP -MF"Test.d" -MT"Test.o" -c -o "Test.o" "Test.c"

 

The version I'm using:

 

powerpc-eabivle-gcc.exe (BLD = 1607) 4.9.4 20160726 (build.sh rev=gceb1328 s=F494 -i /opt/freescale ELe200 -V release_gceb1328_build_Fed_ELe200_ML3)

Can you please help out?

 

Thanks in advance.

Outcomes