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

Is it a compiler bug??

unsigned int Begin;
 ...
Begin=*(U16 CODE *)Begin;

 ...
;---- Variable 'Begin' assigned to Register 'DPTR' ----
002C 8F82              MOV     DPL,R7
002E F583              MOV     DPH,A
                                           ; SOURCE LINE # 82
0030 E4                CLR     A
0031 93                MOVC    A,@A+DPTR
0032 F583              MOV     DPH,A	 <--- Error: This line change the DPTR value.
0034 7401              MOV     A,#01H
0036 93                MOVC    A,@A+DPTR <--- Error: Wrong address.
0037 F582              MOV     DPL,A

Parents
  • Thanks a lot for all your kindly reply!

    I know my code looks weird, such as

    Begin=*(U16 CODE *)Begin;//U16 means unsigned short
    
    In fact, I do it this way for purpose. I run my program on both Target(Real 8051 ICE) and PC(Windows Simulator). See the complete code below...
    void CopyRomData (U8 XDATA *Des,U8 Index)
    {
        U8 CODE *pbSrc;
        unsigned int Begin;//Keil 2B, Win32 4B.
        SysSetRomPage(ROM_PAGE1);//Change Bank, it means the following "MOVC" will retrieve data from specify bank.
        Begin=(unsigned int)&((BankH1 CODE *)0)->OffsetData[Index];//Data offsets are located on begginning of each bank.
        WinWork(winGetRomAddr(&Begin));//For simulator.
        Begin=*(U16 CODE *)Begin;
        WinWork(Begin=U16X(Begin));//Hi-Lo exchange, little-Endian for PC.
        WinWork(winGetRomAddr(&Begin));//For simulator.
        pbSrc=(U8 CODE *)Begin;//Both Target and PC could get the right address.
        strcpy(Des,pbSrc);//I just want to copy string, but keil's library seems refer to 'MOVC' internal(It will access to wrong bank), That's why I wrote a loop myself(see pre post).
        SysSetRomPage(ROM_PAGE0);
    }
    
    

    My target contains 4 banks. I put all my programs on bank#0(prevent bank switch and common area issue), and the others are const data, such as Fonts,Bitmaps,Midi,String(In this case), etc.
    Of course, I have my own tools for creating those bank's images, and , my little simulator could help me to check if there are O.K. or not. When I found the program is O.K. on PC, but error on Target. Then I starting to solve the problem, until I found the compiler's issue that I metion before.

    My CA51-v7.0 product is out of date (1 year/Bought on Sep2002). Can I still download the most update version?

Reply
  • Thanks a lot for all your kindly reply!

    I know my code looks weird, such as

    Begin=*(U16 CODE *)Begin;//U16 means unsigned short
    
    In fact, I do it this way for purpose. I run my program on both Target(Real 8051 ICE) and PC(Windows Simulator). See the complete code below...
    void CopyRomData (U8 XDATA *Des,U8 Index)
    {
        U8 CODE *pbSrc;
        unsigned int Begin;//Keil 2B, Win32 4B.
        SysSetRomPage(ROM_PAGE1);//Change Bank, it means the following "MOVC" will retrieve data from specify bank.
        Begin=(unsigned int)&((BankH1 CODE *)0)->OffsetData[Index];//Data offsets are located on begginning of each bank.
        WinWork(winGetRomAddr(&Begin));//For simulator.
        Begin=*(U16 CODE *)Begin;
        WinWork(Begin=U16X(Begin));//Hi-Lo exchange, little-Endian for PC.
        WinWork(winGetRomAddr(&Begin));//For simulator.
        pbSrc=(U8 CODE *)Begin;//Both Target and PC could get the right address.
        strcpy(Des,pbSrc);//I just want to copy string, but keil's library seems refer to 'MOVC' internal(It will access to wrong bank), That's why I wrote a loop myself(see pre post).
        SysSetRomPage(ROM_PAGE0);
    }
    
    

    My target contains 4 banks. I put all my programs on bank#0(prevent bank switch and common area issue), and the others are const data, such as Fonts,Bitmaps,Midi,String(In this case), etc.
    Of course, I have my own tools for creating those bank's images, and , my little simulator could help me to check if there are O.K. or not. When I found the program is O.K. on PC, but error on Target. Then I starting to solve the problem, until I found the compiler's issue that I metion before.

    My CA51-v7.0 product is out of date (1 year/Bought on Sep2002). Can I still download the most update version?

Children