 |
|
 |
MAEC TOOL NEWS:
MAECT-M3T-NC308WA-020601D
Notes on C Compilers M3T-NC308WA, M3T-NC30WA, M3T-NC79WA, and M3T-NC77WA; and Assemblers AS308, AS30, and AS79
|
Please take note of the following problems in using C compilers (with an assembler and integrated development environment) M3T-NC308WA, M3T-NC30WA, M3T-NC79WA, and M3T-NC77WA:
- On jump addresses in switch statements
- On directive command ".ORG"
- Problem on Jump Addresses in Switch Statements
- 1.1 Products and Versions Concerned
- C compiler for M32C/80 and M16C/80 series MCUs :
- M3T-NC308WA V.1.00 Release 1 -- V.3.10 Release 3
- C compiler for M16C/60, M16C/30, M16C/20, and M16C/10 series MCUs :
- M3T-NC30WA V.1.00 Release 1 -- V.5.00 Release 1
- C compiler for 79xx series MCUs :
- M3T-NC79WA V.2.00 Release 1 -- V.4.10 Release 1
- C compiler for 77xx series MCUs :
- M3T-NC77WA V.3.10 Release 2 -- V.5.20 Release 4
- 1.2 Description
- For switch statements having many jump addresses, the C compiler builds a jump table specifying all the jump addresses, places it in a sequence of execution instructions, and generates codes for indirect jumps by looking up this table.
However, compiling a C-language source file that contains a function in which two or more switch statements are described may lose part of the table to generate wrong codes, resulting in making incorrect jumps.
- 1.3 Conditions
- This problem may occur if the following six conditions are satisfied:
- (1) Option -OR is selected.
- (2) Option -ONBSD (-Ono_break_source_debug) is not selected.
- (3) Option -fST (-fswitch_table) is selected in M3T-NC79WA and M3T-NC77WA.
- (4) Two or more switch statements are described in a function.
- (5) After compilation, at least two switch statements are expanded each to a jump table and the codes that look it up to make indirect jumps.
- (6) The two switch statements in (5) meet either of the following conditions:
- (a) At any jump address of one switch statement exists an expression that is the same as the one residing at any jump address of the other.
- (b) Both switch statements have the path for breaking each statement without program execution in either of the following manners:
- (i) There is a case or default label that contains only a break statement for breaking the switch statement.
- (ii) There is no default label.
- 1.4 Example
[C-language source file]
-----------------------------------------------------------------------
extern int a, b, c, x;
void func(void)
{
if (a) {
switch (b) { /* Condition (4): the 1st switch statement */
case 8:
case 9:
case 11:
case 12:
case 13:
case 14:
case 15:
x++; /* Condition (6)-(a); #1 */
break;
case 10:
x = 2;
break;
default:
x = 0; /* Condition (6)-(a); #2 */
break;
}
} else {
switch (c) { /* Condition (4): the 2nd switch statement */
case 33:
case 34:
case 35:
case 36:
case 37:
case 38:
case 39:
case 40:
x++; /* Condition (6)-(a);
the same expression as #1 above */
break;
default:
x = 0; /* Condition (6)-(a);
the same expression as #2 above */
break;
}
}
}
-----------------------------------------------------------------------
- 1.5 Workaround
- (1) For all the case and default labels that have the same expressions, add a dummy asm function immediately after each of them.
- (2) For all the case and default labels that have only a break statement, also add a dummy asm function in the same way.
- (3) For the switch statements with no default label, place a set of a default label, a dummy asm function, and a break statement in each switch statement.
- Note that when a statement contains several case and default labels, as cases 33 to 40 in the above example, not all the labels but only the last label requires a dummy asm function.
[Example of C-language source file]
-----------------------------------------------------------------------
extern int a, b, c, x;
void func(void)
{
if (a) {
switch (b) {
case 8:
/* Omitted */
case 15:
asm(); /* Dummy asm function */
x++;
break;
case 10:
x = 2;
break;
default:
asm(); /* Dummy asm function */
x = 0;
break;
}
} else {
switch (c) {
case 33:
/* Omitted */
case 40:
asm(); /* Dummy asm function */
x++;
break;
default:
asm(); /* Dummy asm function */
x = 0;
break;
}
}
}
-----------------------------------------------------------------------
- 1.6 Schedule of Fixing the Problem
- We plan to fix this problem in our next release.
Notes on C Compilers M3T-NC308WA, M3T-NC30WA, M3T-NC79WA, and M3T-NC77WA; and Assemblers AS308, AS30, and AS79 MAECT-M3T-NC308WA-020601D
- Problem on Directive Command ".ORG"
- 2.1 Products and Versions Concerned
- C compiler for M32C/80 and M16C/80 series MCUs :
- M3T-NC308WA V.1.00 Release 1 -- V.3.10 Release 3
- C compiler for M16C/60, M16C/30, M16C/20, and M16C/10 series MCUs :
- M3T-NC30WA V.3.20 Release 1 -- V.5.00 Release 1
- C compiler for 79xx series MCUs :
- M3T-NC79WA V.3.20 Release 1 -- V.4.10 Release 1
- Relocatable assembler for M32C/80 and M16C/80 series MCUs :
- AS308 V.1.00 Release 1 -- V.2.00 Release 1
- Relocatable assembler for M16C/60, M16C/30, M16C/20, and M16C/10 series MCUs :
- AS30 V.1.00 Release 1 -- V.3.20 Release 1
- Relocatable assembler for 79xx series MCUs :
- AS79 V.2.00 Release 1 -- V.3.20 Release 1
- 2.2 Description
- Describing more than one ".ORG" directive command in one CODE (program) section may assign more than one instruction to the same address, resulting in incorrect operations being performed.
[Example of assembly-language source file]
--------------------------------------------------------------------
.section prg,CODE
.org 0F0000H
jne lab
:
add.w #1122H, R0
mov.w R0,A0
lab:
.org 0F0100H
add.w #3344H, R0
nop
:
--------------------------------------------------------------------
- 2.3 Condition
- This problem occurs if the following three conditions are satisfied:
- (1) More than one ".ORG" directive command are described in one CODE (program) section.
- (2) Jump instructions or subroutine-call instructions are described after the description of an ".ORG" directive command.
- (3) The location address (LOC.) of an object code generated by assembling is the same as the address specified by the second ".ORG" directive command or later.
- 2.4 Example
[Assembler list file]
--------------------------------------------------------------------
SEQ. LOC. OBJ. 0XMSDA ....*....SOURCE STATEMENT....
1 .section prg,CODE
2 F00000 .org 0F0000H -> Condition 1
3 F00000 DA04 * jne lab -> Condition 2
CEFF00
:
54 F000FD 072211 S add.w #1122H, R0
55 F00100 C1AB mov.w R0,A0 -> Condition 3
57 F00102 lab:
58
59 F00100 .org 0F0100H -> Condition 1
60 F00100 074433 S add.w #3344H, R0
61 F00103 DE nop
:
--------------------------------------------------------------------
- In the above example, two instructions described in lines 55 and 60 are assigned to address 0F0100H and address 0F0101H each.
- 2.5 Workaround
- When describing more than one ".ORG" directive command in one CODE (program) section, define another section name using directive command ".SECTION" and then describe ".ORG" directive commands.
[Example of assembly-language source file]
--------------------------------------------------------------------
.section prg,CODE
.org 0F0000H
jne lab
:
add.w #1122H, R0
mov.w R0,A0
lab:
.section prg_1,CODE -> Definition of another section
by directive command ".SECTION" added.
.org 0F0100H
add.w #3344H, R0
nop
:
--------------------------------------------------------------------
- 2.6 Schedule of Fixing the Problem
- We plan to fix this problem in our next release.
|
 |