This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Big ERROR in C166 4v20

Hi,

there is huge misunderstood in C166, just try this:

#pragma code // and

char * cptr; // and this:


cptr[-1]=*cptr++;

and look at the assmbled machine code.
and ... have a lot of fun ...

Parents
  • To see what really is going on, I would suggest to have a look at the following piece of code:

    void main(void)
    {
    	char xhuge* cptr = (char xhuge*)*(long*)0; // just to see what registers are allocated for cptr
    	cptr[-1]=*cptr++;
    }
    
    You will see that cptr is incremented before evaluation of 'cptr[-1]' and after evaluation of '*cptr', which is perfectly fine. 'cptr[-1]' subtracts 1 from cptr to obtain the right address, which is all right too. What can also be seen is LOTS of redundant MOVs and lack of optimization (the compiler could have used the initial value of cptr in 'cptr[-1]' instead of incrementing the pointer and decrementing it back). I have seen such extravagant use of registers and, consequently, redundant MOVs far too often.

Reply
  • To see what really is going on, I would suggest to have a look at the following piece of code:

    void main(void)
    {
    	char xhuge* cptr = (char xhuge*)*(long*)0; // just to see what registers are allocated for cptr
    	cptr[-1]=*cptr++;
    }
    
    You will see that cptr is incremented before evaluation of 'cptr[-1]' and after evaluation of '*cptr', which is perfectly fine. 'cptr[-1]' subtracts 1 from cptr to obtain the right address, which is all right too. What can also be seen is LOTS of redundant MOVs and lack of optimization (the compiler could have used the initial value of cptr in 'cptr[-1]' instead of incrementing the pointer and decrementing it back). I have seen such extravagant use of registers and, consequently, redundant MOVs far too often.

Children