The CGT 7.4.4 assembler is removing a "NOP 4" instruction from a hand-scheduled assembly function under different code and assembler option scenarios.
First, a little background on the assembly function. The purpose of the function is to set the stack frame prior to calling any C-functions for a specific boot case. The assembly function extracts the stack pointer from a global variable and puts it into B15 and A15. It then jumps to a C initialization function.
The problem I'm seeing is as soon as I try to modify B15 (stack) and A15 (frame) the assembler blows away the "NOP 4" needed after the LDW that loads the stack address from the global variable. I found I can work around the problem by adding the --no_compress option when assembling the file or adding four NOP instructions. Despite the workaround I really can't find, or think of, a reason why the assembler is removing instructions explicitly written in a hand-scheduled assembly file.
I should also note that as a test I replaced the modification B15 and A15 with modification of two arbitrary B and A registers and the assembler DID NOT remove the NOP 4 after the LDW.
I'm attaching four .txt files with the scenarios I've just described. The files contain the asm source, the assembler command, and the output .lst file for each.
"NOP 4" Removed B15/A15 Modified:
test.asm:
glblRecoverStart:
.asg B4, pTempStack
.asg B15, tempStack
.asg A15, tempStack2
.asg A6, restoreAddr
.def glblRecoverStart
.ref endGlblTempStack, globalRestoreInit
MVKL.S2 endGlblTempStack, pTempStack
MVKH.S2 endGlblTempStack, pTempStack
LDW.D2T2 *pTempStack, tempStack
NOP 4
MV.D1X tempStack, tempStack2
MVKL.S1 globalRestoreInit, restoreAddr
MVKH.S1 globalRestoreInit, restoreAddr
BNOP.S2X restoreAddr, 5
Command Line:
C:\>"C:/ti/ccsv5/tools/compiler/c6000_7.4.4/bin/cl6x" -mv6600 --abi=eabi --asm_listing -c --asm_file "C:/test.asm"
test.lst:
TMS320C6x Assembler PC v7.4.4 Tue Dec 03 18:00:38 2013
Tools Copyright (c) 1996-2013 Texas Instruments Incorporated
C:/test.asm PAGE 1
1 glblRecoverStart:
2 .asg B4, pTempStack
3 .asg B15, tempStack
4 .asg A15, tempStack2
5 .asg A6, restoreAddr
6 .def glblRecoverStart
7 .ref endGlblTempStack, globalRestoreInit
8
9 00000000 0200002a! MVKL.S2 endGlblTempStack, pTempStack
10 00000004 0200006a! MVKH.S2 endGlblTempStack, pTempStack
11 00000008 079002e6 LDW.D2T2 *pTempStack, tempStack
12 0000000c 00000000 NOP 4
13 0000000c 07bc18f0 MV.D1X tempStack, tempStack2
14
15 00000010 03000028! MVKL.S1 globalRestoreInit, restoreAddr
16 00000014 03000068! MVKH.S1 globalRestoreInit, restoreAddr
17 00000018 0098b362 BNOP.S2X restoreAddr, 5
No Assembly Errors, No Assembly Warnings
"NOP 4" Remains B15/A15 Modified + --no_compress:
test.asm:
test.asm:
glblRecoverStart:
.asg B4, pTempStack
.asg B15, tempStack
.asg A15, tempStack2
.asg A6, restoreAddr
.def glblRecoverStart
.ref endGlblTempStack, globalRestoreInit
MVKL.S2 endGlblTempStack, pTempStack
MVKH.S2 endGlblTempStack, pTempStack
LDW.D2T2 *pTempStack, tempStack
NOP 4
MV.D1X tempStack, tempStack2
MVKL.S1 globalRestoreInit, restoreAddr
MVKH.S1 globalRestoreInit, restoreAddr
BNOP.S2X restoreAddr, 5
Command Line:
C:\>"C:/ti/ccsv5/tools/compiler/c6000_7.4.4/bin/cl6x" -mv6600 --abi=eabi --asm_listing -c --no_compress --asm_file "C:/test.asm"
test.lst
TMS320C6x Assembler PC v7.4.4 Tue Dec 03 18:01:22 2013
Tools Copyright (c) 1996-2013 Texas Instruments Incorporated
C:/test.asm PAGE 1
1 glblRecoverStart:
2 .asg B4, pTempStack
3 .asg B15, tempStack
4 .asg A15, tempStack2
5 .asg A6, restoreAddr
6 .def glblRecoverStart
7 .ref endGlblTempStack, globalRestoreInit
8
9 00000000 0200002A! MVKL.S2 endGlblTempStack, pTempStack
10 00000004 0200006A! MVKH.S2 endGlblTempStack, pTempStack
11 00000008 079002E6 LDW.D2T2 *pTempStack, tempStack
12 0000000c 00006000 NOP 4
13 00000010 07BC18F0 MV.D1X tempStack, tempStack2
14
15 00000014 03000028! MVKL.S1 globalRestoreInit, restoreAddr
16 00000018 03000068! MVKH.S1 globalRestoreInit, restoreAddr
17 0000001c 0098B362 BNOP.S2X restoreAddr, 5
No Assembly Errors, No Assembly Warnings
"NOP 4" Remains B7/A7 Modified Instead of B15/A15:
test.asm:
glblRecoverStart:
.asg B4, pTempStack
.asg B7, tempStack
.asg A7, tempStack2
.asg A6, restoreAddr
.def glblRecoverStart
.ref endGlblTempStack, globalRestoreInit
MVKL.S2 endGlblTempStack, pTempStack
MVKH.S2 endGlblTempStack, pTempStack
LDW.D2T2 *pTempStack, tempStack
NOP 4
MV.D1X tempStack, tempStack2
MVKL.S1 globalRestoreInit, restoreAddr
MVKH.S1 globalRestoreInit, restoreAddr
BNOP.S2X restoreAddr, 5
Command Line:
C:\>"C:/ti/ccsv5/tools/compiler/c6000_7.4.4/bin/cl6x" -mv6600 --abi=eabi --asm_listing -c --asm_file "C:/test.asm"
test.lst:
TMS320C6x Assembler PC v7.4.4 Tue Dec 03 17:57:25 2013
Tools Copyright (c) 1996-2013 Texas Instruments Incorporated
C:/test.asm PAGE 1
1 glblRecoverStart: ;.cproc
2 .asg B4, pTempStack
3 .asg B7, tempStack
4 .asg A7, tempStack2
5 .asg A6, restoreAddr
6 .def glblRecoverStart
7 .ref endGlblTempStack, globalRestoreInit
8
9 00000000 0200002a! MVKL.S2 endGlblTempStack, pTempStack
10 00000004 0200006a! MVKH.S2 endGlblTempStack, pTempStack
11 00000008 107d LDW.D2T2 *pTempStack, tempStack
12 0000000a 6c6e NOP 4
13 0000000c 039c18f0 MV.D1X tempStack, tempStack2
14
15 00000010 03000028! MVKL.S1 globalRestoreInit, restoreAddr
16 00000014 03000068! MVKH.S1 globalRestoreInit, restoreAddr
17 00000018 0098b362 BNOP.S2X restoreAddr, 5
18 ;.endproc
No Assembly Errors, No Assembly Warnings
4 "NOP" Used Instead of "NOP 4":
test.asm:
glblRecoverStart:
.asg B4, pTempStack
.asg B15, tempStack
.asg A15, tempStack2
.asg A6, restoreAddr
.def glblRecoverStart
.ref endGlblTempStack, globalRestoreInit
MVKL.S2 endGlblTempStack, pTempStack
MVKH.S2 endGlblTempStack, pTempStack
LDW.D2T2 *pTempStack, tempStack
NOP
NOP
NOP
NOP
MV.D1X tempStack, tempStack2
MVKL.S1 globalRestoreInit, restoreAddr
MVKH.S1 globalRestoreInit, restoreAddr
BNOP.S2X restoreAddr, 5
Command Line:
C:\>"C:/ti/ccsv5/tools/compiler/c6000_7.4.4/bin/cl6x" -mv6600 --abi=eabi --asm_listing -c --asm_file "C:/test.asm"
test.lst:
TMS320C6x Assembler PC v7.4.4 Tue Dec 03 18:08:08 2013
Tools Copyright (c) 1996-2013 Texas Instruments Incorporated
C:/test.asm PAGE 1
1 glblRecoverStart:
2 .asg B4, pTempStack
3 .asg B15, tempStack
4 .asg A15, tempStack2
5 .asg A6, restoreAddr
6 .def glblRecoverStart
7 .ref endGlblTempStack, globalRestoreInit
8
9 00000000 0200002a! MVKL.S2 endGlblTempStack, pTempStack
10 00000004 0200006a! MVKH.S2 endGlblTempStack, pTempStack
11 00000008 079002e6 LDW.D2T2 *pTempStack, tempStack
12 0000000c 0c6e NOP
13 0000000e 0c6e NOP
14 00000010 0c6e NOP
15 00000012 0c6e NOP
16 00000014 07bc18f0 MV.D1X tempStack, tempStack2
17
18 00000018 03000028! MVKL.S1 globalRestoreInit, restoreAddr
19 00000020 03000068! MVKH.S1 globalRestoreInit, restoreAddr
20 00000024 0098b362 BNOP.S2X restoreAddr, 5
No Assembly Errors, No Assembly Warnings
Justin