8051 TOOLCHAIN - SOLVED AND KNOWN PROBLEMS

Copyright (c) 2001-2003 Altium BV
Document date: April 07, 2003

This file describes the solved and known problems of version 7.0 revision 5 of the 8051 Toolchain.


SOLVED PROBLEMS
KNOWN PROBLEMS
RESTRICTIONS



SOLVED PROBLEMS


Solved in version v7.0r5:
PR22009 (Linker/Locator): rescanning libraries
PR22306 (Linker/Locator): report by how many bytes a space is overflowing and for which section
PR30316 (IEEE formatter): ieee51 generates E030, caused by declaring CSEG inside a function..
PR30621 (C Compiler): DIV AB instruction may return erroneous result if  A accessed preceding DIV AB
PR30779 (C Compiler): assertion error when assigning a local long to a global char.
PR31449 (C Compiler): incorrect code generated for local bitfield access in reentrant model
PR31478 (C Compiler): use different segment name convention when bank switching is used
PR31479 (EDE): add option to select the output directory.
PR31505 (C Libraries): When selecting the  Infineon MDU  division does not work properly.
PR31509 (Linker): incorrect relocation for variable in bank switch segment
PR31568 (C Compiler): E610 on special case
PR31587 (EDE): default rules file wmk.mk required when using external makefile in EDE
PR31739 (C Compiler): compiler can not handle specific CSE optimization and triggers S571
PR31786 (C Compiler): Add option to output messages from code when  compiling  or assembling.
PR31914 (Archiver): Archiver creates a library that results in fatal linker error 301 when included.
PR32035 (C Compiler): specific case causes assertion error.
PR32092 (Linker): the linker PRINT control does not allow spaces in the map file name
PR32093 (Linker/Locator): add option to suppress linker warnings.
PR32119 (EDE): Feature request:Ability to change the Baudrate to the Cygnal flasher.
PR32212 (C Compiler): segment definitions in inline assembly mess up symbolic debug info

Solved in version v7.0r4:
PR31667 (Miscellaneous): Omf51 formatter generates debug information for only one module
PR31735 (Linker/Locator): basic Intel Omf51 file contains extended type definition records.
PR31737 (C Compiler): MISRA C not working in v7.0 compiler
PR31954 (Miscellaneous): omf formatter generates wrong checksum in specific case

Solved in version v7.0r1:
PR23140 (C Compiler): struct member access after implicit assignment may cause assertion
PR30359 (C Compiler): multiplying unsigned char with -1 & casting to int gives wrong answer

Solved in version v7.0r0:
PR8082 (C Compiler): better code for a=~b
PR21167 (CrossView): rom monitor written in C
PR21864 (C Compiler): feature request - _sfrword support
PR22256 (C Compiler): internal error S 536 for two-dimentional array addressing and large memory model
PR22282 (C Libraries): Atmel AT8x53 multiple data pointers not supported
PR22337 (C examples): banksw example doesn't reserve enough stack space
PR22752 (C Compiler): compiler could optimize MOV Cy,Cy instruction
PR22769 (C Compiler): assertion error 520 for char bitfield assignment with lvalue
PR22807 (C Compiler): compiler does not handle accumulator used as SFR correctly.
PR22987 (C Compiler): #pragma optimize does not accept valid optimization level 3
PR23157 (C Compiler): test on indirect accessed integer variable incorrect
PR23170 (Linker/Locator): give error/warning when an interrupt vector is used with multiple functions
PR30290 (C Compiler): assertion error S533
PR30302 (C Compiler): uninterruptable virtual stack pointer restoration
PR30303 (C Compiler): add option to switch on/off acceptance of keywords without starting underscore
PR30304 (C Compiler): segmentation fault for complex shift right with constant 8
PR30320 (Assembler): symbolic debug generation error for cseg combined with org
PR30355 (CrossView): allow higher speed on comport to speed up ROM-monitor download
PR30486 (C Compiler): S3: assertion failed error using Safer C
PR30491 (C Compiler): signal function signal() and raise() are missing
PR30572 (C Compiler): compiler triggers S003 on specific test case
PR30573 (C Compiler): compile should recognize expression combining 2 characters to an int
PR30594 (C Compiler): optimise shift left with constant 8 and multiplication with 256
PR30597 (C Compiler): assigning a value of a long to an int/char in function gives assertion error
PR30602 (C Compiler): pointing to function using floats generates assertion error.
PR30623 (C Compiler): allow simple interrupt function without accompanying vector
PR30833 (C Compiler): Specific case generates compiler assertion error.
PR30923 (C Compiler): Character parameters may be passed as integers
PR30967 (C Compiler): int >>8 compare with array generates assertion error in large memory model
PR31160 (C Compiler): code generation for bitfields set with constant values can be improved
PR31213 (C Compiler): Example triggers S536 when compiler in reentrant model
PR31220 (EDE): TRUE seems defined as codesense shows #define TRUE 1
PR31272 (Macro Preproc.): incorrect search algorithm for mpp51
PR31288 (C Compiler): wrong register pair used for shift expression
PR31308 (C Compiler): S 546 on function pointer cast of constant
PR31340 (CrossView): _bit cannot be set to one in crossview



SOLVED PR8082: better code for a=~b
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The following bit of code...
short a,b ;
a = ~b ;
generates the following assembly...
MOV A,_B+1
CPL A
MOV R3, A     ; MOV _A+1,A
MOB A,_B
CPL A
MOV R2,A      ; MOV _A,A
MOV _A,R2     ; Not needed in case of using moves
MOV _A+1,R3   ; as listed behind semi-colons above.
The concluding moves could have been done straight away from accumulator A.




SOLVED PR21167: rom monitor written in C
Component: CrossView
Solved in: v7.0r0

DESCRIPTION:
a monitor written in C will make it easier for customers to understand and port.



SOLVED PR21864: feature request - _sfrword support
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
allow a feature to declare sfr-words

EXAMPLE:
_sfrword CCAP0W _at( 0xFA, 0xEA );

void main(void)
{
  CCAP1W += 0x320
}




SOLVED PR22009: rescanning libraries
Component: Linker/Locator
Solved in: v7.0r5

DESCRIPTION:
The assembler manual explains that libraries are not rescanned and thus
the care should be taken how the objects are archived. One step further
would be to support rescanning.




SOLVED PR22256: internal error S 536 for two-dimentional array addressing and large memory model
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The compiler aborts with internal error 536 when using the large memory model and
the example as follows next.


EXAMPLE:
typedef struct
{
  unsigned char a;
  unsigned char b;
} A_t;

extern unsigned char h(void);
extern A_t nodes[][16];

char x;

void g(void)
{
  unsigned char i,j;
  while(i++)
  {
    for (j=0;j<16;j++)
    {
      nodes[i][j].a = 0;
      nodes[i][j].b = 0;
    }
  }
}

void f(void)
{
  unsigned char i;
  while (i)
  {
    i = h();
    nodes[x][i].a = x;
    nodes[x][i].b = x;
  }
}


WORKAROUND:
Swap the order of functions 'f' and 'g'



SOLVED PR22282: Atmel AT8x53 multiple data pointers not supported
Component: C Libraries
Solved in: v7.0r0

DESCRIPTION:
The Atmel AT8x53 multiple data pointers are not supported.



SOLVED PR22306: report by how many bytes a space is overflowing and for which section
Component: Linker/Locator
Solved in: v7.0r5

DESCRIPTION:
When an address space overflows the linker will report which sections could not be located. What it does not report is by how many bytes each individual section overflowed.



SOLVED PR22337: banksw example doesn't reserve enough stack space
Component: C examples
Solved in: v7.0r0

DESCRIPTION:
The banksw example doesn't reserve enough stack space. This will go unnoticed because
no other data is reserved beound the stack.


WORKAROUND:
o add cstart.asm,
o at the very least double the stacksize (it may be less this is a quick guess)




SOLVED PR22752: compiler could optimize MOV Cy,Cy instruction
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
When using the following construction:

    P1_0 = CY;

The compiler generates the following code:

    MOV   C,0D7H
    MOV   P1_0,C

The first move is a dummy one (carry to carry)
and thus can be left out.




SOLVED PR22769: assertion error 520 for char bitfield assignment with lvalue
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The compiler asserts for char bit field members that are assigned an lvalue using
the LARGE memory model.


EXAMPLE:
typedef struct
{
  char a:1;
} A_t;
  
A_t aa;

char a;

void f(void)
{
  aa.a = a;
}


WORKAROUND:
(a) integer bitfield replacement

typedef struct
{
  unsigned a:1;
} A_t;
  
A_t aa;

char a;

void f(void)
{
  aa.a = a;
}

(2) temporary value insertion

typedef struct
{
  char a:1;
} A_t;
  
A_t aa;

char a;

void f(void)
{
  char temp = a;
  aa.a = temp;
}




SOLVED PR22807: compiler does not handle accumulator used as SFR correctly.
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
When the accumulator is explicitly used in C code, using the
SFR address. It is not always handled correctly by the compiler.


EXAMPLE:
void main( void )
{
    while ( ACC & 0xff )
        /* NOP */ ;
}


WORKAROUND:
Do not use the accumulator SFR in this way, instead use
inline assembly if it is really required.




SOLVED PR22987: #pragma optimize does not accept valid optimization level 3
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The #pragma optimize does not accept the valid optimization level 3.

EXAMPLE:
#pragma optimize 3

void main( void )
{
}




SOLVED PR23140: struct member access after implicit assignment may cause assertion
Component: C Compiler
Solved in: v7.0r1

DESCRIPTION:
A struct member usage after an implicit assignment may cause a
compiler assertion.


EXAMPLE:
typedef struct
{
    int mem;
} t_str;

t_str x1, x2;

void main( void )
{
    if ( (x1 = x2).mem )
    {
        x2.mem++;
    }
}


WORKAROUND:
First do the assigment before accessing the struct member.



SOLVED PR23157: test on indirect accessed integer variable incorrect
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The code generated for a test on a indirect accessable integer
variable is incorrect.


EXAMPLE:
_idat int y;

void main( void )
{
    if ( y )
    {
        y++;
    }
}

/* code generated:
   MOV R1,#_y
   MOV A,@R1
   ORL A,@R1

The INC R1 instruction is missing, thus actually
only the high byte of 'y' is tested.
*/




SOLVED PR23170: give error/warning when an interrupt vector is used with multiple functions
Component: Linker/Locator
Solved in: v7.0r0

DESCRIPTION:
When 2 functions are defined using the same interrupt vector no
error or warning is generated.


EXAMPLE:
_interrupt(1) void ISR1( void )
{}

_interrupt(1) void ISR2( void )
{}




SOLVED PR30290: assertion error S533
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The following is a case of an assertion error S533. It occurs when the reentrant memory
model is used.


EXAMPLE:
extern char * aa;
extern char bb;

char f(char i)
{
  char f0;
  char f1;
  
  char * f2;

  if (i)
  {
    return f0 = bb;
  }
  else
  {
    if (f2 = aa)
    {
      _nop();
    }
    return f1 = aa[i];
  }

}


WORKAROUND:
As there is no reason to assign 'f1' with 'aa[i]' the case can be reduced to the sample below still having the same functionalty. This time, there is no assertion.

extern char * aa;
extern char bb;

char f(char i)
{
  char f0;
  
  char * f2;

  if (i)
  {
    return f0 = bb;
  }
  else
  {
    if (f2 = aa)
    {
      _nop();
    }
    return aa[i];
  }

}




SOLVED PR30302: uninterruptable virtual stack pointer restoration
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
By including VSP in the _frame qualifier the compiler PUSHes/POPs __SP(+1) its data onto
the stack. While restoring the virtual stack pointer it should temporarily disable
interrupts as it may be interrupted by an interrupt routine of higher priority which will
then - by chance - use a partly restored virtual stack pointer.


EXAMPLE:
The current implementation:

_interrupt(1) _frame(VSP) void isr(void) { /* whatever */ }

assembly:

_?isr:
        USING   0
        PUSH    __SP
        PUSH    __SP+1
        POP     __SP+1

             +----------------> this is the dangerous part, may NOT be interrupted

        POP     __SP
        RETI


WORKAROUND:
Only if the isr can be interrupted by one of a higher priority one must do the PUSHing and POPing oneself as demonstrated below:

_interrupt(1) void isr(void)
{

   #pragma asm
   push __SP
   push __SP+1
   #pragma endasm

   /* whatever comes next */

   #pragma asm
   push 0A8h       ; save IE to stack
   pop  ACC        ; effectively load IE into ACC
   clr  0AFH       ; disable all interrupts
   pop  __SP+1     ; restore #1
   pop  __SP       ; restore #2
   push ACC        ; save ACC (=IE) to stack
   pop  0A8h       ; effectively restore IE
   #pragma endasm

}
  




SOLVED PR30303: add option to switch on/off acceptance of keywords without starting underscore
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
Currently the compiler accepts most storage specifiers with and without
a starting underscore (data, _data, xdat, _xdat). The variant without
starting underscore is non-ANSI, and may result in conflicts with user
variables. Add an option to switch on/off the acceptance of storage
qualifiers without an underscore.




SOLVED PR30304: segmentation fault for complex shift right with constant 8
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The following example using a complex shift right with constant value 8
will cause a segmentation fault.


EXAMPLE:
typedef struct
{
    int ix;
    char jx;
    struct
    {
        long lx;
        char cx;
    } sx;
} t_str;

_xdat t_str arr[10];

unsigned char hx;
unsigned int gy;

void main( void )
{
    gy = (unsigned int)(&arr[2].sx.cx) >> 8;
}




SOLVED PR30316: ieee51 generates E030, caused by declaring CSEG inside a function..
Component: IEEE formatter
Solved in: v7.0r5

DESCRIPTION:
When declaring CSEG inside a function the ieee51 formatter comes
with the following error:

Creating IEEE-695 absolute file < filename >.abs
ieee51 E030: syntax error at symbol #< number >

<filename> = name of the file.
<number> = a number (t.ex 36)
(this number varies with the location of the code.)


EXAMPLE:
void f1(void)
{
#pragma asm;
    CSEG AT 0x2000      
    DB  'Hello'        
#pragma endasm;
}


WORKAROUND:
/* Declare CSEG outside the function. */
#pragma asm;
    CSEG AT 0x2000      
    DB  'Hello'        
#pragma endasm;

void f1(void)
{
}




SOLVED PR30320: symbolic debug generation error for cseg combined with org
Component: Assembler
Solved in: v7.0r0

DESCRIPTION:
The assembler generates incorrect symbolic debug for the following
case using a CSEG statement followed by an ORG.


EXAMPLE:
cseg
    org    0123H;



WORKAROUND:
use

cseg at 100H;org    0100h

instead




SOLVED PR30355: allow higher speed on comport to speed up ROM-monitor download
Component: CrossView
Solved in: v7.0r0

DESCRIPTION:
Within EDE only baudrates of 9600 and 19k2 are supported, some fast targets
could run on higher baudrates.


EXAMPLE:
GOTO EDE Crossvieuw-Pro-options  Rom-monitor Baudrates.
You can only select 9600 and 19200 Baud.

Same complaint goes for lower baudrates.


WORKAROUND:




SOLVED PR30359: multiplying unsigned char with -1 & casting to int gives wrong answer
Component: C Compiler
Solved in: v7.0r1

DESCRIPTION:
When multiplying an unsigned char with -1 and storing the answer in an integer
a wrong value is calculated.


EXAMPLE:
#include <stdio.h>
int i;
unsigned char c=1;
void main (void)
{
    i=-1*c;
    printf("i= %d",i);
}


WORKAROUND:
Use 0-1 and put this in front.
#include <stdio.h>
int i;
unsigned char c=1;
void main (void)
{
    i=0-1*c;
    printf("i= %d",i);
}

Use - variable instead.
#include <stdio.h>
int i;
unsigned char c=1;
void main (void)
{
    i=-c;
    printf("i= %d",i);
}




SOLVED PR30486: S3: assertion failed error using Safer C
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The compiler issues "S3 assertion error" instead of
"Safer C rule 53 violation" when compiling the following
example with an empty for-loop initialization.


EXAMPLE:
int i;

void main(void)
{
    for (;;)
    {
        i++;
    }
}



WORKAROUND:
Fill in the for-loop initilization, or disable
Safer C rule 53.




SOLVED PR30491: signal function signal() and raise() are missing
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
According to ANSI signals should be supported through
the signal functions signal() and raise() (include file signal.h).
Also abort() should be supported (prototype in <stdlib.h>).


EXAMPLE:
n.a.

WORKAROUND:

Add signal.h to  the include ( \include )directory of EDE.
Add the following files to the project:
  signal.c
  raise.c
  abort.c
( all files attached to PR)




SOLVED PR30572: compiler triggers S003 on specific test case
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The compiler triggers S003 on a certain test case.


EXAMPLE:
void main(void)
{
    unsigned long l=0x00;
    unsigned long* test = &l;

    1 = 0x00;
    
        while ( l <= 1 )    
    {
        do
            {
                 l= l >>  1;  
            } while ( l );
            l = (l - 1)  << 1;
        }
}




SOLVED PR30573: compile should recognize expression combining 2 characters to an int
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The compiler should recognize the following type of expression:
   z = (unsigned int)(x<<8) | y;
which combines 2 characters to an int. Instead of generating complex
shift code it should put 'x' in the high byte, and 'y' in the low
byte.


EXAMPLE:
#define SFRWORD(low,high)   (volatile unsigned int)((high<<8)|low)

_sfrbyte CRCL _at(0x85);
_sfrbyte CRCH _at(0x90);

_inline volatile unsigned int GetCRC( void )
{
    return SFRWORD(CRCL,CRCH);
}

unsigned int x;

void main( void )
{
    x = GetCRC();
/* should optimally result in:
*     mov _x,090H
*     mov _x+1,085H
*/
}




SOLVED PR30594: optimise shift left with constant 8 and multiplication with 256
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The compiler should recognize left shift with constant 8 and multiplication
with 256 and use it to generate far more efficient code.


EXAMPLE:
unsigned int gx;
unsigned int gy;

void f( void )
{
    gx = gy << 8;
}

void g( void )
{
    gx = gy * 256;
}




SOLVED PR30597: assigning a value of a long to an int/char in function gives assertion error
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
Assigning a value of a long to an int/char in function may result in
a compiler assertion error.





EXAMPLE:
unsigned int value1;

void function(signed long param1)
{
    value1 = param1;
}

void main (void)
{
    function(0x00);
}


WORKAROUND:
/* use an extra (local) variable.*/
unsigned int value1;

void function(signed long param1)
{
    unsigned int extra;

    extra =param1;
    value1 =extra;
}

void main (void)
{
    function(0x00);
}




SOLVED PR30602: pointing to function using floats generates assertion error.
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
When using a function pointer to a function which uses floats
an assertion error may occur.


EXAMPLE:
float value,a;
float f1(float a)
{
    return --a;
}
float f_x(float in,float (*f_ptr)(float))
{
    return f_ptr(in);
}
void main (void)
{
    value = f_x(1, &f1 );
}


WORKAROUND:
Use a temporary variable:

float value,result,a;
float f1(float a)
{
    return --a;
}

float f_x(float in,float (*f_ptr)(float))
{
    result= f_ptr(a);/* work around */
    return result;   /* work around */
}

void main (void)
{
    value = f_x(1, &f1 );
}




SOLVED PR30621: DIV AB instruction may return erroneous result if  A accessed preceding DIV AB
Component: C Compiler
Solved in: v7.0r5

DESCRIPTION:
Dallas semiconductor errata sheet for the DS80C390 Rev. B3:
6. The DIV AB instruction may return erroneous results if the A register is accessed    immediately preceding the DIV AB instruction.
t.ex.:
MOV B, #data
MOV A, #data
DIV AB ;*INCORRECT*

Work Around:
   It is common programming practice to load both the A and B registers
   right before executing the DIV AB.Either of the following two
   programming approaches will execute correctly.

MOV A, #data            MOV B, #data
MOV B, #data            MOV A, #data
DIV AB ;CORRECT         NOP
                        DIV AB ;CORRECT



EXAMPLE:
#include <stdio.h>
unsigned char count=0;
unsigned char value;
unsigned char test;
void main(void)
{
    while (1)
    {
        ++count;
        test=10;
        value=count/test;
/*
Above Generates the following code which gives erroneous
results according to Dallas errata sheet.:

main#11:        MOV     B,#0ah
code:0bh:       MOV     A,_count
code:0dh:       DIV     AB
code:0eh:       MOV     _value,A
*/
        printf("Value=%d",value);
    }
}




SOLVED PR30623: allow simple interrupt function without accompanying vector
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
In some case it is required to have a interrupt function without the
accompanying vector. E.g in case of the EZ-USB chip which has several
interrupt functions linked to the same vector address.


EXAMPLE:
_interrupt(-1) void ISR(void)
{
}




SOLVED PR30779: assertion error when assigning a local long to a global char.
Component: C Compiler
Solved in: v7.0r5

DESCRIPTION:
testcase generates error:S529 assertion failed.



EXAMPLE:
#include <stdio.h>
char a;

void f(void)
{
    long b;
    b=a;
    a=b;

}


void main(void)
{
        f();
}


WORKAROUND:
#include <stdio.h>
char a;

void f(void)
{
    long b;
    b=a;
    a=(long)(char)b;

}


void main(void)
{
        f();
}




SOLVED PR30833: Specific case generates compiler assertion error.
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The following example generates a compiler assertion error.


EXAMPLE:
char str[1];
int y;

long f1(char s)
{
    return s;
}
void f2(char x)
{
        y = (str[x] <<1 )+str[x];
}




SOLVED PR30923: Character parameters may be passed as integers
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
When calling a function through a function pointer, character variables may be passed
as integer values. When the called function retreives the parameters as a char a wrong
value may be the result.


EXAMPLE:
_reentrant void func(char c)
{
         return (c);
}

_reentrant void (*f)(char c) = func;

void main(void)
{
    (*f)( 1 ); /* parameter is passed as 'int' instead of 'char' */
}



WORKAROUND:




SOLVED PR30967: int >>8 compare with array generates assertion error in large memory model
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The following example containing a compare with an int shifted 8, results
in S536 from the compiler when compiled for the large memory model.


EXAMPLE:
char array[ 2 ];
int b;

void main (void)
{
    if ( array[1] != (b >> 8 ) )
    {
        b=0;
    }
}


WORKAROUND:
char array[ 2 ] ;
int b ;
void main (void)
{
    if(array[1] != *(unsigned char*)(unsigned int*)&b )
    {
        b=0;
    }
}




SOLVED PR31160: code generation for bitfields set with constant values can be improved
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
When bitfields are set with a constant value a generic runtime routine
is called to set this value. Instead some and/or instructions would have
sufficed.


EXAMPLE:
struct
{
    unsigned int b1:1;
} bf;

void main( void )
{
    bf.b1 = 1;
}




SOLVED PR31213: Example triggers S536 when compiler in reentrant model
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The following example triggers S 536.

EXAMPLE:
typedef struct
{
    unsigned char *m_p;
    unsigned char *m_b;
} t_str;

extern int i( void );

void f( t_str *p, int x, unsigned char *y )
{
    p->m_p = y;
}

void g( t_str *p, unsigned char b )
{
    if ( i() )
    {
        p->m_p[p->m_b] = b;
        p->m_b = 0;
    }
}


WORKAROUND:
Disable CSE optimization for the module.



SOLVED PR31220: TRUE seems defined as codesense shows #define TRUE 1
Component: EDE
Solved in: v7.0r0

DESCRIPTION:
TRUE seems defined as codesense shows #define TRUE 1
because the 8051 examples are standard included in Codesense Global Configuration.


EXAMPLE:
Type TRUE in a project and jump on it with the mouse
codesense will show the #define TRUE 1 as it was used in the examples
the same goes for FALSE.


WORKAROUND:
Goto Customize | Codesense Global Configuration ,
deactivate the example files, < Apply > , < OK >




SOLVED PR31272: incorrect search algorithm for mpp51
Component: Macro Preproc.
Solved in: v7.0r0

DESCRIPTION:
The search algorithm used by the macro preprocessor does not match with
the compiler. Mpp51 does not look in the directory of the source file
but instead in the directory from where it is called.


WORKAROUND:
Use the -I<dir-of-source-file> option



SOLVED PR31288: wrong register pair used for shift expression
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The compiler optimizes expressions of type (x<<8)|y by directly
placing x and y in the corresponding byte registers, however
in some situations the wrong register pair is used.




SOLVED PR31308: S 546 on function pointer cast of constant
Component: C Compiler
Solved in: v7.0r0

DESCRIPTION:
The compiler triggers an error S 546 on a valid function pointer
cast of a constant value.


EXAMPLE:
typedef void (*t_functionptr)( void );

void main( void )
{
    ((t_functionptr)0x1234)();
}


WORKAROUND:
typedef void (*t_functionptr)( void );

void main( void )
{
    t_functionptr fptr = (t_functionptr)0x1234;
    fptr();
}




SOLVED PR31340: _bit cannot be set to one in crossview
Component: CrossView
Solved in: v7.0r0

DESCRIPTION:
Incoming Phonecall:
_bit variable cannot be changed to one in crossview

Start Crossview, doubleclick on the variable,add watch,
close,double click on the data window value, change the value to 1.
The value has now changed to 0.


EXAMPLE:
#include <stdio.h>
volatile _bit bit1=1;
void main(void)
{
    while (1)
    {
        bit1 = ~bit1;
    }

}



WORKAROUND:
Change the value to -1 instead, this works.




SOLVED PR31449: incorrect code generated for local bitfield access in reentrant model
Component: C Compiler
Solved in: v7.0r5

DESCRIPTION:
In the reentrant model incorrect code is generated for local bitfield
access.


EXAMPLE:
typedef struct
{
   unsigned char b0 : 1;
} t_str;

unsigned char gx;

void main( void )
{
    unsigned char loc;

    if ( ((t_str *)&loc)->b0 == 1 )
    {
        gx++;
    }
}




SOLVED PR31478: use different segment name convention when bank switching is used
Component: C Compiler
Solved in: v7.0r5

DESCRIPTION:
When bank switching is used the segment name convention may cause
linker errors due to two-way references between some common segments and
function segments. E.g. some switches result in constants in a C51_CO segment
with references to the switch-cases, on the other hand the switch refers
the C51_CO segment. Since the C51_CO is a very common segment this may
result in linker error E129, code references between different banks.


EXAMPLE:
/* compile with -Mr and -S */
int gx;

_rom char *str = "Hello world";

void main( void )
{
    switch ( gx )
    {
    case 1:
        gx++;
        break;
    case 100:
        gx+=10;
        break;
    case 1000:
        gx*=5;
        break;
    default:
    case 1234:
        gx+=5;
        break;
    }
}




SOLVED PR31479: add option to select the output directory.
Component: EDE
Solved in: v7.0r5

DESCRIPTION:
Add an option to EDE to select an output directory for generated files.


EXAMPLE:




SOLVED PR31505: When selecting the  Infineon MDU  division does not work properly.
Component: C Libraries
Solved in: v7.0r5

DESCRIPTION:
In the Libary UDIVI.ASM when the Infineon MDU is defined
generated code for a division does not work.


EXAMPLE:
A division is made as follows:

_1:        PUSH    IE            ; make sure the calculation is uninterrupted
        CLR    EA
        MOV    MD0,R7
        MOV    MD1,R6
        MOV    MD4,R5
        MOV    MD5,R4            ; this write triggers the DIV operation
;(here the 6 NOPs are missing)
        MOV    R7,MD0
        MOV    R6,MD1
        MOV    R5,MD4
        MOV    R4,MD5

        CLR    C            ; no division by zero
        POP    IE            ; restore the original interrupt enable register




SOLVED PR31509: incorrect relocation for variable in bank switch segment
Component: Linker
Solved in: v7.0r5

DESCRIPTION:
incorrect relocation for variable in bank switch segment



SOLVED PR31568: E610 on special case
Component: C Compiler
Solved in: v7.0r5

DESCRIPTION:
Testcase attached. The reason for the E610 is the compiler switch -noregaddr.


EXAMPLE:
/*
* compiling with -noregaddr triggers E 610
*/
void f1(void)
{
    int value ;
    while(1)
      {
        if (value)
        {
            value &= 0x01 ;
        }
       }
}



WORKAROUND:
Turn Allow register automatic variables (R0-R7) OFF



SOLVED PR31587: default rules file wmk.mk required when using external makefile in EDE
Component: EDE
Solved in: v7.0r5

DESCRIPTION:
When using an external makefile in the EDE->build options you might
get the following warning:   "cannot find wmk.mk"

And resulting from that possible errors like:
"wmk: Don't know how to make <file>.c"

Reason is that the generic 'wmk.exe' utility is called from EDE,
this generic make utility lacks an accompanying default rules
file 'wmk.mk'.


WORKAROUND:
Copy the mk51.mk file to wmk.mk



SOLVED PR31667: Omf51 formatter generates debug information for only one module
Component: Miscellaneous
Solved in: v7.0r4

DESCRIPTION:
When using multiple modules in a project the Omf51
formatter generates debug information for only one module.


EXAMPLE:
// =GM= file1:            

unsigned char ratoon;
void main (void)
{
}

// =GM= end of file1.

// =GM= file2:    

    unsigned char misty;

// =GM= end of file2.    




SOLVED PR31735: basic Intel Omf51 file contains extended type definition records.
Component: Linker/Locator
Solved in: v7.0r4

DESCRIPTION:
When selecting basic Intel Omf51 format generation (omf51 -i option)
the generated file still contains type definition records.


EXAMPLE:
void main( void )
{
}




SOLVED PR31737: MISRA C not working in v7.0 compiler
Component: C Compiler
Solved in: v7.0r4

DESCRIPTION:
Activating MISRA C in v7.0 results in the following error message:

F 554: illegal memory type specified
wmk: *** action exited with value 2.





SOLVED PR31739: compiler can not handle specific CSE optimization and triggers S571
Component: C Compiler
Solved in: v7.0r5

DESCRIPTION:
The compiler triggers S571 on the following example, it is
caused by not being able to handle the CSE optimization.


EXAMPLE:
unsigned char c1, c2;
_bit b1;

void f( void )
{
    b1 = ((c1 & 0x10) != 0);
    c2 = ((c1 & 0x10) != 0);
}




SOLVED PR31786: Add option to output messages from code when  compiling  or assembling.
Component: C Compiler
Solved in: v7.0r5

DESCRIPTION:
Add functionality for the C compiler to output messages like:

#pragma message message text

And also for the assembler:

$message(text)


EXAMPLE:
#pragma message 19200Baud





SOLVED PR31914: Archiver creates a library that results in fatal linker error 301 when included.
Component: Archiver
Solved in: v7.0r5

DESCRIPTION:
Creating a library with the archiver results in fatal linker error
when the library is included in a project


EXAMPLE:
n.a.

WORKAROUND:
Use version 6.0 archiver (ar51.exe) instead.



SOLVED PR31954: omf formatter generates wrong checksum in specific case
Component: Miscellaneous
Solved in: v7.0r4

DESCRIPTION:
omf formatter generates wrong checksum in specific case


EXAMPLE:
N.A.

WORKAROUND:
N.A.



SOLVED PR32035: specific case causes assertion error.
Component: C Compiler
Solved in: v7.0r5

DESCRIPTION:
Specific case causes S 533:  assertion failed


EXAMPLE:
void f1(unsigned int a, unsigned int *p1)
{
    unsigned int b;
    unsigned char c;
    while  (b)
    {
        c =*p1;
        *(unsigned char * )a = c;
        b--;
        p1++;          
        if (a|b);            
    }
}


WORKAROUND:
#pragma optimize W  //UK switch off register variables as a workaround





SOLVED PR32092: the linker PRINT control does not allow spaces in the map file name
Component: Linker
Solved in: v7.0r5

DESCRIPTION:
The linker PRINT control does not support spaces in the filename,
when used the linker will exit with a fatal error F201:

link51 F201: invalid commandline syntax '.L51'


EXAMPLE:
link51 test.obj -o test.out PR("filename with space.l51")

WORKAROUND:
Specify a map filename without a space in it.



SOLVED PR32093: add option to suppress linker warnings.
Component: Linker/Locator
Solved in: v7.0r5

DESCRIPTION:
The compiler supports suppressing specific or all warnings, add a similar
option to suppress linker warnings.


EXAMPLE:




SOLVED PR32119: Feature request:Ability to change the Baudrate to the Cygnal flasher.
Component: EDE
Solved in: v7.0r5

DESCRIPTION:
Feature request:Ability to change the Baudrate to the Cygnal flasher.



SOLVED PR32212: segment definitions in inline assembly mess up symbolic debug info
Component: C Compiler
Solved in: v7.0r5

DESCRIPTION:
When using segment definitions in inline assembly symbolic debug
info may get messed up causing an ieee conversion error:
   Parser error: syntax error at symbol #52


EXAMPLE:
------------------------
test.c
------------------------
void f( void )
{
#pragma asm
XYZ SEGMENT DATA
    RSEG XYZ
_x: DS 1

    RSEG TEST_F_PR
#pragma endasm
}

void main( void )
{
    f();
}


WORKAROUND:
Move the segment definitions outside of the function


KNOWN PROBLEMS


PR5234 (CrossView): memory dump on breakpoint should show original code
PR5334 (CrossView): application error when opening logfile in nonexisting dir
PR5359 (Assembler): asm51 accepts out of range org
PR5726 (C Compiler): Conversion requested from 'float' to 'unsigned int'
PR6599 (CrossView): scroll asm window backwards, error when address < 0
PR6605 (CrossView): XVW> pointer=array; No check on memory space
PR6919 (C Compiler): function name/case sensitive compiler problem
PR7020 (CrossView): 'DN' monitor command doesn't work for HEX files
PR7490 (C Compiler): Overlay problem with 'function call return value arg'
PR7864 (Linker/Locator): linker error 121
PR7914 (Macro Preproc.): mpp51: %EXIT causes problems
PR8352 (CrossView): viewing a two-dimensional array fails in Crossview
PR8553 (CrossView): _sfrbit variables cannot be altered from register window
PR8813 (Linker/Locator): link51: fatal error 240: internal error, number 205
PR8934 (Linker/Locator): FO control should accept _PR of section name
PR8990 (CrossView): setting a bit via data window doesn't work
PR9078 (CrossView): add other support file types to 'download image'
PR9079 (CrossView): selected file type for 'download image' ignored
PR9091 (Macro Preproc.): %IN doesn't work within EQS command
PR20105 (EDE): error line should refer to line within file being processed
PR20241 (Make Utility): order of dependencies related to time stamp
PR20243 (C Libraries): access to wrong memory space.
PR20264 (CrossView): profiling doesn't include RET
PR20476 (Linker/Locator): locating control that overlays sections by force
PR20823 (Linker/Locator): filling gaps with predefined value
PR20840 (Macro Preproc.): Macro Preprocessor prepends $ when using $INCLUDE control
PR20971 (Macro Preproc.): mpp51 can not handle bracketed escape properly
PR21174 (Linker/Locator): issue warning 4 also when _at() sections overlap
PR21997 (Macro Preproc.): Macro preprocessor leaves parenthesis
PR22008 (Linker/Locator): improving the locating algorithm
PR22092 (Linker/Locator): better type checking between object modules
PR22210 (Simulator): support viewing statics even when another module is loaded
PR22474 (Linker/Locator): unreal linker error 307 when using AUX memory model and XPAGE other than 0
PR22576 (Linker/Locator): change behaviour of linker FO control with wildcard (FO(SEGA ] *))
PR22792 (Linker/Locator): fatal error 240 if COMMON area is too small
PR22822 (CrossView): Crossview Pro does not support 2 stop bits in serial communication
PR22876 (Macro Preproc.): space insertion for quoted macro
PR22931 (Linker/Locator): Debug info for absolute _pdat variables incorrect for XPAGE > 0
PR30314 (Linker): fixup error for LARGE memory model and XPAGE <> 0
PR30360 (C Compiler): signed char multiplied with -1 and converted to int gives wrong value.
PR30422 (Simulator): No simulator support for the Temic T89C51RD2
PR30651 (C Compiler): Example with local _pdat variable causes assertion error S 536.
PR30958 (CrossView): reset behaviour of some registers not simulated correctly
PR31043 (EDE): Automatically use #define FORM_CONST when this is selected in EDE
PR31515 (C Compiler): Compiler halts with E581 when _using() and _inline functions are mixed.
PR31540 (C Libraries): fgetc sometimes returns wrong value.
PR31682 (C Compiler): x *= -1 optimized away.
PR31884 (Simulator): interrupt reset mechanisme incorrectly simulated
PR31888 (Simulator): Incorrect reset values for some 80C552 SFRs


KNOWN PR5234: memory dump on breakpoint should show original code
Component: CrossView

DESCRIPTION:
When a breakpoint is set the inserted LCALL can be seen by directly
requesting the contents of the code address where the breakpoint is set.
This is corrected when the address is disassembled. Requesting the contents
of the same code address after a disassemble, correctly returns the original
code.
This problem does not apply to the emulator and simulator versions of
Crossview.


WORKAROUND:
First disassemble



KNOWN PR5334: application error when opening logfile in nonexisting dir
Component: CrossView

DESCRIPTION:
XVW for Windows will issue an application error when
you try to open a logfile in a non-existing directory.
This may occur if you have enabled Autostart and you have removed the
log directory that you selected earlier.




KNOWN PR5359: asm51 accepts out of range org
Component: Assembler

DESCRIPTION:
ASM51 should give error on:

XX SEGMENT CODE
RSEG  XX
ORG $-2  ; negative result




KNOWN PR5726: Conversion requested from 'float' to 'unsigned int'
Component: C Compiler

DESCRIPTION:
Casting values >32768 from double to unsigned int will fail.

EXAMPLE:
unsigned int c;
double d=40000;
c=(unsigned int)d;   /* Unpredictable result */


WORKAROUND:
Use a temporary 'long' cast:
unsigned int c;
double d=40000;
c=(unsigned int)((long)d);   /* c==40000 */




KNOWN PR6599: scroll asm window backwards, error when address < 0
Component: CrossView

DESCRIPTION:
Scrolling the assembly window backwards causes an error when the program
address passes zero.




KNOWN PR6605: XVW> pointer=array; No check on memory space
Component: CrossView

DESCRIPTION:
XVW doesn't allways check if an expression is legal.
Examples:
xvw> pointer = array
xvw> pointer = &variable
XVW evaluates the given expressions even if 'array' and 'variable' are
located in other memory spaces than pointed to by 'pointer'.




KNOWN PR6919: function name/case sensitive compiler problem
Component: C Compiler

DESCRIPTION:
Functions having equal names, only difference is
uppercase/lowercase, in same translation unit result
in assembler errors. Although the function names are
different (ANSI casesensitiveness) the code segment
names are equal. This is not ANSI compliant behavior.


EXAMPLE:
void AAP(void) {return;}
void aap(void) {return;}
Results in assembler error:
8051 assembler v4.0 r0                 SN068107-008 (C)1995 Tasking SoftwareV
12  TEST_AAP_PR     SEGMENT CODE
**** ERROR 52 (test.src, line #12): DUPLICATE SEGMENT NAME, SEGMENT ALREADY
DEFINED
Both AAP() and aap() result in the same segment name definition:
TEST_AAP_PR     SEGMENT CODE


WORKAROUND:
Don't use function names that only differ in case.



KNOWN PR7020: 'DN' monitor command doesn't work for HEX files
Component: CrossView

DESCRIPTION:
Using the 'DN' command an Intel HEX file can be downloaded. However
when viewing source/assembly level, the code memory appears to
contain only 'MOV R7,A' opcodes. The HEX file seems not to be
downloaded properly.


EXAMPLE:
Linker Mapfile excerpt for reset vector:
CODE    0000H   0003H    ABSOLUTE
HEX file, record containing reset vector:
:03000000120003E8
XVW, View/Assembly level disassembly:
code:00h:         MOV R7,A
code:01h:         MOV R7,A
code:02h:         MOV R7,A
....




KNOWN PR7490: Overlay problem with 'function call return value arg'
Component: C Compiler

DESCRIPTION:
A function takes, among ordinary arguments, a 'function
call return value' argument. Because both functions
are not alive at the same time, their static data
areas are overlayed by the linker.
This however results in the corruption of the
function arguments. This is caused by the fact that
the compiler first evaluates the ordinary arguments.
Next the 'function call return value' is evaluated.
During the latter evaluation overlayed data memory
is modified, resulting in corruption of the 'ordinary
arguments'.


EXAMPLE:
fa( fb(), <ordinary arguments> )

fb ()
{
    fc()
}
The ordinary arguments are put in data memory first, next the
"fb()" argument is evaluated. This evaluation results in a function
call sequence that shares data memory with fa() leaving the ordinary
arguments corrupted.


WORKAROUND:
Put the 'function call return value' in a temporary
variable, then call the other function with the
temporary variable as the argument.




KNOWN PR7864: linker error 121
Component: Linker/Locator

DESCRIPTION:
The following example results in error 121 from the
linker when both ORGs are raised with 800H i.e. 2K.
NAME MYTEST
MYTEST_C SEGMENT CODE
RSEG MYTEST_C
ORG (0000H) ; ORG(0800H)
LABEL:
ORG (07FDH)
AJMP LABEL  ; ORG(0FFDH)
END
Both AJMPs are valid and remain within the same page
address however the second instance - replacing the ORGs
with those succeeding the semi colons - results in formentioned
error message.


WORKAROUND:
In real practice the example as provided will happen
when the total amount of assembly code is larger than
2K and it continues in the next page. Eventhough the
jump can be achieved the linker doesn't allow it. The
only way to solve this is to make sure that the total
amount of code is less than 2K i.e. split up the module
in smaller ones.




KNOWN PR7914: mpp51: %EXIT causes problems
Component: Macro Preproc.

DESCRIPTION:
The following example causes the macro preprocessor to
exit with error 304 :
%*DEFINE(FOO(P1,P2))(
%IF(%EQS(%P1,a))
THEN
( %EXIT )
FI
%IF(%EQS(%P2,b))
THEN
( ; comment )
FI
)

%FOO(a,b)


WORKAROUND:
mpp51 doesn't deal with %EXIT the way it should. Avoid
using it by :
- 1 - splitting the macro into two new ones each taking
care of one %IF statement.
- 2 - Rewrite the macro using a nested %IF contruction.




KNOWN PR8352: viewing a two-dimensional array fails in Crossview
Component: CrossView

DESCRIPTION:
The following cut-down version from the customer cannot
be watched from CrossView:
_rom char aString[][4] = {"AAA" ,"BBB" ,"CCC"} ;
int aTest(_rom char x[][4])
{
/* some code */
aVar = x[i][j] ;
/* other code */
}
The assignment of 'aVar' is okay but there appears to be
no way of watching 'x'.




KNOWN PR8553: _sfrbit variables cannot be altered from register window
Component: CrossView

DESCRIPTION:
_sfrbit variables cannot be altered from the register window.

EXAMPLE:
Try altering P1_7. It won't work.

WORKAROUND:
Change the variables concerned using the _bitbyte from which the _sfrbit
variables have been derived.




KNOWN PR8813: link51: fatal error 240: internal error, number 205
Component: Linker/Locator

DESCRIPTION:
Using the following assembly source the linker aborts with internal error 240
$CASE
NAME X
PUBLIC aByte
C51_BA SEGMENT DATA BITADDRESSABLE
RSEG C51_BA
aByte: DS 1
bitOne BIT aByte.0
bitTwo BIT aByte.1
END


WORKAROUND:
Set bit 1 of DEBUGINFO (at least). This boils down to adding the following
control:
$DEBUGINFO(002H)




KNOWN PR8934: FO control should accept _PR of section name
Component: Linker/Locator

DESCRIPTION:
Currently the linker doesn't accept the succeeding _PR of a code section
when used for the FUNCTIONOVERLAY control.
Suppose A_MAIN_PR 'calls' A_ISR_PR then the following isn't accepted:
FO(A_MAIN_PR ] A_ISR_PR)
And linker error 250 is illegally issued since both section do exist.


WORKAROUND:
Use FO(A_MAIN ] A_ISR) instead



KNOWN PR8990: setting a bit via data window doesn't work
Component: CrossView

DESCRIPTION:
Trying to update a bit via the datawindow of crossview
doesn't work. As an example...
_bit x = 1 ; extern void f(void) ;
void main(void) {
while (1)
{
if (x) {
f() ;
}
}
}
after clearing the bit via datawindow it can never be set
via this same window.


WORKAROUND:
Use a bit via a bitbyte variable and use the bitbyte to
do your updates. An implementation might be:
_bitbyte BITS _at(0x20);
_bit bit0 _atbit(BITS, 0);




KNOWN PR9078: add other support file types to 'download image'
Component: CrossView

DESCRIPTION:
Currently CrossView Pro assumes a file type 'abs' only when you go through
the following menu sequence:
file | download image | file | files of type
This shows you a list of 'abs' only. What if you want to look for a hex file?


WORKAROUND:
enter '*.hex' into 'file name' and press enter



KNOWN PR9079: selected file type for 'download image' ignored
Component: CrossView

DESCRIPTION:
Via...
file | download imaga | formats
CrossView Pro allows you to select a file format. Having done this it flicks
back to the default 'autodetect'.


WORKAROUND:
let autodetect do its work



KNOWN PR9091: %IN doesn't work within EQS command
Component: Macro Preproc.

DESCRIPTION:
The %IN command doesn't work in the EQS command

EXAMPLE:
%OUT(Y/N ?)
%IF(%EQS(%IN,Y)) THEN (
;etc etc
The expression will always yield false


WORKAROUND:
The following equivalent:
%OUT(Y/N?)
%DEFINE(ARG)(%IN)
%IF(%EQS(%ARG,Y)) THEN (




KNOWN PR20105: error line should refer to line within file being processed
Component: EDE

DESCRIPTION:
When the macro preprocessor report an error it relates the line number to the
expanded - non existing - file. The error parser string however will search
for this line number within the file being processed.




KNOWN PR20241: order of dependencies related to time stamp
Component: Make Utility

DESCRIPTION:
The "$!" control of the make utility allows you to pass all of the modules that
are listed after the ":" in the makefile. However the order (for a build) it seems
to derive from the time stamps of those modules i.e. the eldest come first. For
the 8051 toolchain this can be a disadvantage for cstart.asm. Only changing this
module and pressing build makes it the last module on the linker command line
which will seriously effect run-time behaviour as cstart.asm MUST be the first
module on the linker command line.


EXAMPLE:
$(PROJ).out : 6007strt.obj 6007k110.obj 6007k210.obj 6007k310.obj i2cbits1.obj
    D:\cc5141r1\bin\link51.exe _<<EOF
  ${separate ",\n" $(match .obj $!) $(match .lib $!)}

For an initial make the order for "$!" will be:

  6007strt.obj
  6007k110.obj
  6007k210.obj
  6007k310.obj
  i2cbits1.obj

When changing 6007strt.asm the order becomes:

  6007k110.obj
  6007k210.obj
  6007k310.obj
  i2cbits1.obj
  6007strt.obj

Note "6007strt.obj" becomes the last module on the linker command line.


WORKAROUND:
Force a rebuild



KNOWN PR20243: access to wrong memory space.
Component: C Libraries

DESCRIPTION:
A structure located in code space isn't properly addressed
when it contains an array of pointers.


EXAMPLE:
typedef struct
{
    int * p[1];
} _rom P_t;

int a;

P_t b = { &a };

int * p;

int f(int c)
{
    p = b.p[c];

    return (p == &a);
}

void main(void)
{
    f(0);
}


WORKAROUND:
Don't locate the structure in code space or use a different coding strategy.



KNOWN PR20264: profiling doesn't include RET
Component: CrossView

DESCRIPTION:
The profiling feature of the simulator doesn't include RET in its report.

EXAMPLE:
void f(void) {
  _nop() ;
  _nop() ;
  _nop() ;
}

Total time of "f" : 6*(3+2) = 30 states

However CrossView calculates : 6*3 = 18 states


WORKAROUND:
add 12 states to what you read from the profiling report



KNOWN PR20476: locating control that overlays sections by force
Component: Linker/Locator

DESCRIPTION:
Currently the linker will not overlay datasection of caller and callee.
However, for some cases variables are dead on invocation and may be
overlayed anyway. The linker will not overlay but a user might want to
knowing the variable is dead. In that case it would be nice to have a
linker control that supports this.




KNOWN PR20823: filling gaps with predefined value
Component: Linker/Locator

DESCRIPTION:
Add a feature to allow the linker to fill in the gaps with a predefined value

WORKAROUND:
Use prefill feature of prommer and secondly load in the hex file



KNOWN PR20840: Macro Preprocessor prepends $ when using $INCLUDE control
Component: Macro Preproc.

DESCRIPTION:
The macro preprocessor emits a $ character on every file it includes.

EXAMPLE:
NAME A

%IFDEF (WINNT) THEN (
$INCLUDE (REG51.INC)
) FI

END

Assembler....

NAME A


# 1 "REG51.INC"

# 5 "a.asm"
$                    $ save nolist

For which the assembler reports...

                     5  $                    $ save nolist
**** ERROR 57 (a.asm, line #5): ILLEGAL CONTROL "$"


WORKAROUND:
Add a newline to the top of the file being included,



KNOWN PR20971: mpp51 can not handle bracketed escape properly
Component: Macro Preproc.

DESCRIPTION:
The macro preprocessor has special function for escaping text parts.
However it has sometimes problems with handling the bracket escape
function:   %(<escaped text>)


EXAMPLE:
%*DEFINE(NewName(Name))
(
    x%(Name)y EQU 1
)

NewName(abcd)   ;should result in: xabcdy EQU 1




KNOWN PR21174: issue warning 4 also when _at() sections overlap
Component: Linker/Locator

DESCRIPTION:
currently the linker doesn't issue warning 4 when _at() sections overlap.



KNOWN PR21997: Macro preprocessor leaves parenthesis
Component: Macro Preproc.

DESCRIPTION:
the macro preprocessor does not work out parenthesis correctly,
see examples


EXAMPLE:
%*DEFINE (VAR) ( 1 SHL 5  )

%*DEFINE (ZUWEIS(PARA))
( %PARA )

%ZUWEIS(%VAR)

results in:  1 SHL 5  


%*DEFINE (VAR) ( 1 SHL (5)  )   <- extra parenthesises around 5

%*DEFINE (ZUWEIS(PARA))
( %PARA )

%ZUWEIS(%VAR)

results in:   1 SHL (5)    )   <- parenthesis left!

same result if (5) is replaced by e.g. (8+7)




KNOWN PR22008: improving the locating algorithm
Component: Linker/Locator

DESCRIPTION:
In some cases the linker's locator algorithm is not entirely optimal.
The algorithm can still be improved a lot.




KNOWN PR22092: better type checking between object modules
Component: Linker/Locator

DESCRIPTION:
The linker is incapable of detecting the following type mismatch:

a.c
---

char str[] = {"mismatch"} ;

b.c
---

extern char * str;

This is just one example. Another is the example below. The different types
for 'f' will not be detected but result in serious run time problems.

/* a.c */

extern _reentrant void f(void);
void g(void) { f(); }

/* b.c */

void f(void) { /* user code */ }




KNOWN PR22210: support viewing statics even when another module is loaded
Component: Simulator

DESCRIPTION:
CrossView doesn't view a static when another module is loaded.



KNOWN PR22474: unreal linker error 307 when using AUX memory model and XPAGE other than 0
Component: Linker/Locator

DESCRIPTION:
The linker aborts with error message 307 in the AUX memory model and XPAGE other
than 0. It only occurs if two overlayable functions having minimum overlayable
data (e.g. 1 byte each; enough to fit it within the auxiliary page) call one another.


EXAMPLE:
/* AUX memory model and XPAGE other than 0 */

     void f(void) {
       char a[1];
       while (a[0]);
     }

     void main(void) {
       char a[1];
       f();
       while (a[1]);
     }


WORKAROUND:
Either use the LARGE memory model as a replacement OR disable function overlay OR set XPAGE to 0.



KNOWN PR22576: change behaviour of linker FO control with wildcard (FO(SEGA ] *))
Component: Linker/Locator

DESCRIPTION:
When using an explicit FO control e.g. FO(B ] C) then the
call graph will contain a call from B to C. This means
that if for instance segment A calls segment B it will
not be overlayed with segment C (due to the A->B->C relation).
When in this case the control FO(B ] *) is used the
linker does not overlay B with any other segment (which is
correct) however it does not assume the relation between
A and B, and therefor it still may overlay A with C.


EXAMPLE:
void c( void )
{}

void b( void )
{}

void a( void )
{
    b();
}

void main( void )
{
    a();

    c();
}

In this example data from function 'a()' may be overlayed with 'c()'.
If we use FO(B ] C) then the linker inserts the call 'b()' to 'c()'
and the overlaying is not done ('a()' calls 'b()' calls 'c()').
But if we use FO(B ] *) the linker does not overlay data from
funtion 'b()' but it does not insert the call 'b()' to 'c()', thus
data from function 'a()' is still overlayed with that of 'c()'.


WORKAROUND:
Use the explicit overlay control for all calls from function 'b()'.



KNOWN PR22792: fatal error 240 if COMMON area is too small
Component: Linker/Locator

DESCRIPTION:
When the common area is too small to allow a proper located for a banked application
it may result in fatal error 240.


WORKAROUND:
Most likely reason why the error occured is because the size of the indivual code or constant sections are too large. This makes the common area too small. Therefore the resolution must be made smaller which, from an EDE point of view, can be done as follows:

   (1) select 'EDE | comp. ops. | proj. ops. | misc | additional options',
   (2) enter -Rpr and -Rco

This should provide better results. If the error remains please contact TASKING support.




KNOWN PR22822: Crossview Pro does not support 2 stop bits in serial communication
Component: CrossView

DESCRIPTION:
None.




KNOWN PR22876: space insertion for quoted macro
Component: Macro Preproc.

DESCRIPTION:
The macro preprocessor inserts a space for a quoted macro.

EXAMPLE:
The sample below:

%*define (string) (test)

foo segment code
rseg foo

_1:  db '%string'

end

Will expand to:

# 1 "a.asm"


foo segment code
rseg foo

_1:  db 'test '

end


WORKAROUND:
Do the quoting in the macro itself:

%*define (string) ('test')

foo segment code
rseg foo

_1:  db %string

end




KNOWN PR22931: Debug info for absolute _pdat variables incorrect for XPAGE > 0
Component: Linker/Locator

DESCRIPTION:
When an absolute _pdat variable is used in the a XPAGE > 0 the debug
info still contains an address as if it is located in XPAGE 0.


EXAMPLE:
_pdat int x _at( 0x35 );   /* problem if XPAGE > 0 */

WORKAROUND:
The accompanying assembly label _x contains the correct address



KNOWN PR30314: fixup error for LARGE memory model and XPAGE <> 0
Component: Linker

DESCRIPTION:
The linker produces fixup errors when using the XPAGE control in the LARGE memory model.

EXAMPLE:
#include <stdio.h>

char a;

void main(void)
{
  printf("&a : %X\n", &a);
}

Using  XPAGE(0F8h) RE(XD(0000h,0F7FFh)) for the linker debugging shows the
following for the address of 'a' (while the mapfile says it to be at 0F800h):

    MOV    DPTR,#_printf_BYTE+2
    MOV    A,#000h                  ; HIGH (_a)
    MOVX    @DPTR,A
    MOV    A,#000h                  ; LOW (_a)


WORKAROUND:
Do not use XPAGE for the LARGE memory model. Note that this also means one cannot declare _pdat variables in this same memory model unless they reside in the first segment (XPAGE is assumed 0 by default).




KNOWN PR30360: signed char multiplied with -1 and converted to int gives wrong value.
Component: C Compiler

DESCRIPTION:
Wrong conversion of signed char when multiplying with -1 and casting to integer when
value of signed char is -128


EXAMPLE:
#include <stdio.h>

int i;
signed char c=-128;

void main (void)
{
    i=-1*c;
    printf("c=%d  i= %d\n",c,i);
}


WORKAROUND:
use i=-c; instead.



KNOWN PR30422: No simulator support for the Temic T89C51RD2
Component: Simulator

DESCRIPTION:
Although the compiler/EDE support the T89C51RD2 (Temic) it is not yet supported
by the simulator.




KNOWN PR30651: Example with local _pdat variable causes assertion error S 536.
Component: C Compiler

DESCRIPTION:
Example with local _pdat variable causes assertion error S 536.

EXAMPLE:
typedef struct
{
    unsigned char m1;
    unsigned char m2;              
} str_t;

unsigned char f2;

void func( str_t *cfg )
{
    _pdat unsigned int f1;

    f1 = cfg->m2;
    f2 = (unsigned char)(f1 >> 8) | (unsigned char)(cfg->m1);
}


WORKAROUND:
Do not use the _pdat qualifier for the local variable.



KNOWN PR30958: reset behaviour of some registers not simulated correctly
Component: CrossView

DESCRIPTION:
Incorrect values are used as reset values in the simulator.


EXAMPLE:
The simulator assigns wrong value to the following registers at startup:
P0 = 00H  instead of 0FFH
P1 = 00H  instead of 0FFH
        
A CPU-Reset in the simulator does not affect the following registers:        
IE
IP
P0
P1
PCON
SCON
TH0
TH1
TL0
TL1
TMOD


WORKAROUND:

Goto Edit Macro's  -New -
Create a new macro called reset with the following command options + any other value
you would like to reset(start with rst.):

rst;$ACC=00H;$B=00H;$DPH=00H;$DPL=00H;$IE=$IE&040H;$IP=$IP&0C0H;$P0=0FFH;$P1=0FFH;$P2=0FFH;$P3=0FFH;$PSW=00H;$SCON=00H;$PCON=$PCON&07FH;$SP=07H;$TH0=00H;$TH1=00H;$TL0=00H;$TL1=00H;$TMOD=00H;

Save the macro and use autosave and autoload to reload the macro.




KNOWN PR31043: Automatically use #define FORM_CONST when this is selected in EDE
Component: EDE

DESCRIPTION:
When within EDE the option is selected to have the printf/scanf format
specifier in ROM, you still have to set the FORM_CONST define yourselve.
This could somehow have been done by EDE.




KNOWN PR31515: Compiler halts with E581 when _using() and _inline functions are mixed.
Component: C Compiler

DESCRIPTION:
Problem when an inline function is used within an ISR and this inline function calls another function.
Normally one should use the _using keyword in this case.
But this fails since the compiler complaints:E 581: different register bank ('using')


EXAMPLE:
void _using(3) f2(void);
_inline  void f1(void)
{
      f2();
}
_interrupt(4) _using(3) void x(void)
{
    f1();
}


WORKAROUND:
use _inline or _using(..) for both functions



KNOWN PR31540: fgetc sometimes returns wrong value.
Component: C Libraries

DESCRIPTION:
fgetc sometimes returns wrong value.

EXAMPLE:
#include     <stdio.h>
#include     <simio.h>
volatile int      b_s;
void main (void)
{
    while(1)
    {
        b_s = fgetc((FILE*)3);
    }
}




KNOWN PR31682: x *= -1 optimized away.
Component: C Compiler

DESCRIPTION:
The compiler generates no code for a multiplication of an integer with -1
t.ex b*= -1;


EXAMPLE:
         signed int b=3;
         signed int z;
         void main (void)
         {
         b*=-1;
         P1=b;
         }


WORKAROUND:
make b volatile:

        volatile signed int b=3;
         signed int z;
         void main (void)
         {
         b*=-1;
         P1=b;
         }




KNOWN PR31884: interrupt reset mechanisme incorrectly simulated
Component: Simulator

DESCRIPTION:
The simulator incorrectly simulates an interrupt reset mechanism.
After a RETI the interrupt level should be set to the level as it
was before the interrupt was acknowledged. The simulator however
always resets it to the program level allowing all interrupts
to be acknowledged again.




KNOWN PR31888: Incorrect reset values for some 80C552 SFRs
Component: Simulator

DESCRIPTION:
The following 80C552 registers do not get in the initial state after the
'rst' command.
ADCON
CTCON
CMH2
CMH1
CMH0
CML2
CML1
CML0
IEN1
IP1
P4      (This is a very special case, this port is forced to 00h instead of FFh)
PWMP
PWM1
PWM0
RTE
S1ADR
S1DAT
S1CON
STE
TMH2
TML2
TM2CON
TM2IR

It seems that P4 is forced to 00h, all the other registers simply stay
unchanged.

Also the Watchdogtimer T3 can not be changed in the 'register view'.
Forcing a quick watchdog trip by setting it 'manual' to FFh in the
register view is not possible.



RESTRICTIONS


PR8427 (C Compiler): no character arithmetic for unary operator ~ and -
PR21866 (C Compiler): case study - optimisation request when addressing SFRs
PR22142 (C Compiler): no compiler warning for assigning function to function pointer of different type
PR22151 (C Compiler): unnecessary pointer reloads for register optimised pointer
PR22204 (C Compiler): inefficient pointer optimisation
PR22226 (C Compiler): data propagation can be improved for if expression
PR22260 (C Compiler): warning for unexpected integer promotions of character expressions
PR22465 (Linker/Locator): linker call and jump optimisation
PR22495 (C Compiler): Optimize for speed option not always efficient
PR22935 (C Compiler): Allow a single segment name for an entire C module
PR22973 (C Compiler): allow space selection for virtual stack
PR23018 (C Compiler): generic pointer support
PR23068 (C Compiler): allow separate routines for signed shift right and unsigned shift right
PR23116 (C Compiler): signed to unsigned character comparison can be improved
PR30755 (C Compiler): volatile _xdat variable can be optimized away
PR31235 (C Compiler): allow _at() on more types


RESTRICTION PR8427: no character arithmetic for unary operator ~ and -
Component: C Compiler

DESCRIPTION:
The following example:

typedef unsigned char Byte;
extern idat Byte non_cmd[];
#define FULL_SCALE_CMD       0x80
#define Get_parameter(x) (non_cmd[(x) + 1])
Byte test_macro(void)
{
return((~Get_parameter(0)) ?
( Get_parameter(0) >> 1) : FULL_SCALE_CMD);
}
Doesn't use character arithmetic for the right operand of the unary
operator ~. Instead it promotes it to an integer leading to large
code-size.

The manual states that it can only use character arithmetic if the
result is the same as if done using integer arithmetic. But why then
have a 'use character arithmetic' flag?
So change the behavior of the 'character arithmetic' flag.


WORKAROUND:
Use a cast as follows:
Byte test_macro(void)
{
return(((char)~Get_parameter(0)) ?
( Get_parameter(0) >> 1) : FULL_SCALE_CMD);
}




RESTRICTION PR21866: case study - optimisation request when addressing SFRs
Component: C Compiler

DESCRIPTION:
for addressing sfr's there are cases where the compiler could've generated
less code than it did.


EXAMPLE:
Try this one:

void f(void)
{
  CCAP1H += CY + 0x03;
}




RESTRICTION PR22142: no compiler warning for assigning function to function pointer of different type
Component: C Compiler

DESCRIPTION:
The compiler doesn't issue a warning when a function is assigned to a
function pointer of a different type. This can cause problems if the
pointer is dereferenced.


EXAMPLE:
Note that the example below, because it doesn't warn of the type mismatch,
allows 'f' to be assigned to 'p' and next be envoked.

typedef void (*VV_t)(void);

int x;

void f(int a)
{
  x=a;
}

void main(void)
{
  VV_t p = f;
  p();
}




RESTRICTION PR22151: unnecessary pointer reloads for register optimised pointer
Component: C Compiler

DESCRIPTION:
The compiler reloads a register optimised pointer each time it is addressed
within a loop iteration. Throughout the entire loop the pointer however
remains constant. Only one load would do.


EXAMPLE:
#define FAIL  0

#define LOW   (unsigned char *)0x08
#define HIGH  (unsigned char *)0xFF

void test (void)
{
  register unsigned char * ptr = LOW;
  register unsigned char pattern = 0x55;
  register unsigned char tempval;

  while (1)
  {
    do
    {
      tempval = *ptr;
      *ptr = pattern;
      if (*ptr != pattern) pattern = FAIL;
      *ptr = tempval;
    } while ((ptr++ < HIGH) && (pattern != FAIL));
    ptr = LOW;
  }
}




RESTRICTION PR22204: inefficient pointer optimisation
Component: C Compiler

DESCRIPTION:
The following is an example where the compiler propagates the address constant
for the first pointer decrements without difficulty i.e. it directly loads
DPTR with 0x1003 and 0x1002 upon the next dereference. For the third decrement
all of a sudden it backups the current DPTR into __PARM0 and then derefences
0x1001. Upon the fourth dereference it restores the __PARM0 area into temporary
registers, decrements those and stores them into DPTR to finally derefence
them. The __PARM0 area had not been necessary.


EXAMPLE:
void main(void)
{
  _xdat char *p = (_xdat char *)0x1003;
  
  b <<= 1;

  *p-- = 0x00;
  *p-- = 0x00;
  *p-- = 0xA0;
  *p-- = 0x3F;
}


WORKAROUND:
Use the following code replacement:

typedef union
{
    float real;
  char raw[4];
} FLOAT_t;
  
_xdat float a _at(0x1000) ;

int b;

void f(void)
{

  _xdat FLOAT_t * p = (_xdat FLOAT_t *) 0x1000;
  
  b <<= 1;
  
  p->raw[0] = 0x3F;
  p->raw[1] = 0xA0;
  p->raw[2] = 0x00;
  p->raw[3] = 0x00;
  
}

void main(void)
{

  f();

  if ( a == 1.25 )
  {
    _nop(); // good !
  }
  
}




RESTRICTION PR22226: data propagation can be improved for if expression
Component: C Compiler

DESCRIPTION:
The following case demonstrates the compiler not seeing that 'b' equals 2
at the point of addressing *a[b]. It proceeds to calculate a+b but could've
sufficed with a+2. Note that when b=2 is added to the code inside the if
statement all of a sudden the compiler does see its advantages and propagates
its constant.


EXAMPLE:
volatile unsigned char * a[3];

unsigned char f(unsigned char b)
{
  if ( b == 2 )
  {
    //b=2;
    *a[b];
  }
}

Assemly:

; a.c         5   if ( b == 2 )
    ?LINE   5
    MOV A,R7
    CJNE    A,#02H,_3
; a.c         6   {
; a.c         7     //b=2;
; a.c         8     *a[b];
    ?LINE   8
    MOV A,R7
    ADD A,# LOW (_a)
    MOV R1,A
    MOV A,@R1
    MOV R1,A
    MOV A,@R1

If b=2 is uncommented:

; a.c         5   if ( b == 2 )
    ?LINE   5
    MOV A,R7
    CJNE    A,#02H,_4
; a.c         6   {
; a.c         7     b=2;
; a.c         8     *a[b];
    ?LINE   8
    MOV R1,_a+2
    MOV A,@R1




RESTRICTION PR22260: warning for unexpected integer promotions of character expressions
Component: C Compiler

DESCRIPTION:
Although justfully, integer promotions of characters, often leed to unexpected results.
A warning will therefore speed up the time finding the cause.


EXAMPLE:
example 1
---------

char c;

char f(void) { return ~c ? 0 : 1 ; }

example 2
---------

char a;
char b;

char f(void)
{
  return a == ~b ;
}


WORKAROUND:
A work-around doesn't apply here. In all examples a proper (char) cast should've been used.



RESTRICTION PR22465: linker call and jump optimisation
Component: Linker/Locator

DESCRIPTION:
Allow the linker to optimise LCALLs into ACALLs if the call range allows
so (same thing for LJMPs); a candidate for reducing code size.




RESTRICTION PR22495: Optimize for speed option not always efficient
Component: C Compiler

DESCRIPTION:
The optimize for speed option does not always result in more
efficient code. Given the following example:

volatile _bit test;

void main( void )
{
    while ( test )
       ;
}

Results in the following code, when compiled with optimize for speed:

    JNB _testje,_4
_3:
    JB  _testje,_3
_4:

When compiled with optimize for size the compiler just generates:

_3:
    JB _testje,_3

Which is just as fast, but less code.


WORKAROUND:
Use optimize for size.



RESTRICTION PR22935: Allow a single segment name for an entire C module
Component: C Compiler

DESCRIPTION:
Currently the compiler generates unique segment names per function.
To be able to locate an entire C module to a specific location it
would be easier if a single segment name can be used for the entire
C module.




RESTRICTION PR22973: allow space selection for virtual stack
Component: C Compiler

DESCRIPTION:
Allow users to indicate that the virtual stack be located in either internal ram,
external ram or short (paged) external ram.




RESTRICTION PR23018: generic pointer support
Component: C Compiler

DESCRIPTION:
Generic pointers or a generic pointer memory model might proof a usefull feature.



RESTRICTION PR23068: allow separate routines for signed shift right and unsigned shift right
Component: C Compiler

DESCRIPTION:
allow separate routines for signed shift right and unsigned shift right



RESTRICTION PR23116: signed to unsigned character comparison can be improved
Component: C Compiler

DESCRIPTION:
The code generated for a signed to unsigned character comparison
can be improved.


EXAMPLE:
unsigned char ux;
signed char sy;

char f( void )
{
    return ( ux == sy );
}

will generate:
    MOV    A,_sy
    JB     0E7H,_4
    XRL    A,_ux
_4:
    JZ     _5
    MOV    A,#0FFH
_5:
    INC    A
    RET

while it could have been:
    MOV    A,_sy
    JB     0E7H,_4
    XRL    A,_ux
    JZ     _5
_4:
    MOV    A,#0FFH
_5:
    INC    A
    RET




RESTRICTION PR30755: volatile _xdat variable can be optimized away
Component: C Compiler

DESCRIPTION:
Access to volatile variable can be improved. When compiling the
following example the compiler generates one MOV DPTR,#_x too many.


EXAMPLE:
volatile _xdat unsigned char x;

void main( void )
{
    x = (x & 0x07) | 0x08;
}

//  Results in:
//    main:           MOV     DPTR,#_x
//    code:0476h:     MOVX    A,@DPTR
//    code:0477h:     ANL     A,#07h
//    code:0479h:     MOV     DPTR,#_x  ; This code is not required
//    code:047ch:     ORL     A,#08h
//    code:047eh:     MOVX    @DPTR,A




RESTRICTION PR31235: allow _at() on more types
Component: C Compiler

DESCRIPTION:
Currently the _at() keyword is restricted to uninitialized variables,
while it could be allowed for initialized variables as well as functions too.