The MCU I used is SM8958A,which has 1K bytes on-chip RAM, 256 bytes of it are the same as general 8052 internal memory structure while the expanded 768 bytes on-chip RAM can be accessed by external memory addressing method (by instruction MOVX).The SCONF and RCON should be setting when the expanded 768 bytes on-chip RAM is used.The meaning of RCON is below:
SM8958A has 768 byte on-chip RAM which can be accessed by external memory addressing method only. (By instruction MOVX). The address space of instruction MOVX @Rn is determined by bit 1 and bit 0 (RAMS1, RAMS0) of RCON. The default setting of RAMS1, RAMS0 bits is 00 (page0).
RAMS1 RAMS0 MOVX @Ri i=0,1 mapping to expended RAM address 0 0 $0000 ~ $00FF 0 1 $0100 ~ $01FF 1 0 $0200 ~ $02FF
Now I write the code below:
unsigned long pdata a; unsigned long xdata b; SCONF |= 0x02; //enable the 768 Ram RCON |= 0x01; //$0100 ~ $01FF
When I press F5, I find the position of 'a' in the memory is X:0x0001A4,and the auto disassemble instruction is mov r0, #0xA4, however,the position of 'b' in the memory is X:0x0002BF,and the auto disassemble instruction is movx DPTR,#02BF.
Finally, the program where used 'a' runs wrong,but the program where used 'b' runs right.
But when I program the HEX file into the MCU, let it run in the hardware , the program runs ok.
So, I'm very puzzled: Keil's Debug is right or wrong?
Note This message was edited to reduce width.
In simulation, P2 is the uppermost address of pdata variable, but in real mcu, P2 is no effect . So I guess keil's simulation have some flaw.