Corrected: L251 code optimization does not remove common
blocks for unused functions. These code blocks remains inside the
image. Example:
unsigned char a, b, c;
unsigned char darr [0x10];
void FuncA (void) {
darr[c] = darr[b];
}
void FuncB (void) {
darr[c] = darr[b];
}
void FuncC (void) {
darr[c] = darr[a] + darr[b];
}
void FuncD (void) {
darr[c] = darr[a] + darr[b];
}
void main(void) {
FuncA ();
FuncB ();
while(1);
}
; FUNCTION FuncA (BEGIN) ; FUNCTION FuncB (BEGIN) ; FUNCTION FuncC (BEGIN) ; FUNCTION FuncD (BEGIN)
R MOV A,#LOW darr R MOV A,#LOW darr R MOV A,#LOW darr ----- + ----- R MOV A,#LOW darr
R ADD A,b R ADD A,b R ADD A,b | R ADD A,b
MOV R0,A ----- + ----- MOV R0,A MOV R0,A | MOV R0,A
MOV A,@R0 | MOV A,@R0 MOV A,@R0 | MOV A,@R0
MOV R7,A | MOV R7,A MOV R7,A | MOV R7,A
R MOV A,#LOW darr | R MOV A,#LOW darr R MOV A,#LOW darr ----- + ----- R MOV A,#LOW darr
R ADD A,c | R ADD A,c R ADD A,a | R ADD A,a
MOV R0,A | MOV R0,A MOV R0,A | MOV R0,A
MOV @R0,AR7 ----- + ----- MOV @R0,AR7 MOV A,@R0 | MOV A,@R0
RET | RET ADD A,R7 | ADD A,R7
o-> Common code for FuncA and FuncB MOV R7,A | MOV R7,A
R MOV A,#LOW darr | R MOV A,#LOW darr
R ADD A,c | R ADD A,c
MOV R0,A | MOV R0,A
MOV @R0,AR7 | MOV @R0,AR7
RET | RET
o-> Common code for FuncC and FuncD
In the example above the functions FuncC() and FuncD() are
removed when the REMOVEUNUSED linker directive is
specified. Now, the first part of the common code block (FUNCTION
?L?COM0001) is no longer necessary. In previous verions this was
still part of the image. With the new linker enhancement even
this code block is removed.
----- FUNCTION ?L?COM0001 (BEGIN) -----
000021 7408 MOV A,#LOW darr ---+
000023 2519 ADD A,b |\
000025 F8 MOV R0,A | \
000026 E6 MOV A,@R0 | o-> Common code for FuncC and FuncD
000027 FF MOV R7,A |
000028 7408 MOV A,#LOW darr ---+
00002A ?L?COM0002:
00002A F8 MOV R0,A ---+
00002B E6 MOV A,@R0 |\
00002C FF MOV R7,A | \
00002D 7408 MOV A,#LOW darr | o-> Common code for FuncA and FuncB
00002F 251A ADD A,c |
000031 F8 MOV R0,A |
000032 A607 MOV @R0,AR7 ---+
000034 22 RET
----- FUNCTION ?L?COM0001 (END) -------