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

Why the following bitwise & doesn't work?

unsigned char tp;
unsigned char volatile pdata HOSTCFG2 _at_ 0x0020;
// HOSTCFG2=0x40 at this point
tp=HOSTCFG2 & 0x40;

//!!! tp is 0x00 instead of 0x40 which is expected

//Corresponding Disassembly:

C:0x08F1    7820     MOV      R0,#HOSTCFG2(0x20)
C:0x08F3    E2       MOVX     A,@R0
C:0x08F4    5440     ANL      A,#HPWRSTATE(0x40)
//Why it refers 0x40 as an address instead of a constant here?
C:0x08F6    F508     MOV      0x08,A
   189:         if ((HOSTCFG2 & 0x40)==0x00)


Thanks.

Parents
  • uVision does not automatically alter the startup code to fit the dialog box values. Those values are used for the debugger, and some of the command-line parameters to the compiler and linker. (See the "linker control string" box on the LX51 tab in uVision.)

    But they do not get passed in to STARTUP.A51. You must alter that file yourself.

    Did you get a link error when building this project? The assembler code shown is certainly wrong, since the DPTR isn't being loaded with the proper address. All zeroes makes me think that offset wasn't updated.

Reply
  • uVision does not automatically alter the startup code to fit the dialog box values. Those values are used for the debugger, and some of the command-line parameters to the compiler and linker. (See the "linker control string" box on the LX51 tab in uVision.)

    But they do not get passed in to STARTUP.A51. You must alter that file yourself.

    Did you get a link error when building this project? The assembler code shown is certainly wrong, since the DPTR isn't being loaded with the proper address. All zeroes makes me think that offset wasn't updated.

Children