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

How to change the DATA memory usage ?

Dear all,
I have one question about DATA memory usage.

Original situation:(quoted from .m51 file)

...
fno = 0x00;iflag=arg2;  // C-code and below is machine code
C:0x0E38    78A1     MOV      R0,#fno(0xA1)
C:0x0E3A    F6       MOV      @R0,A
C:0x0E3B    78AF     MOV      R0,#arg2(0xAF)
C:0x0E3D    E6       MOV      A,@R0
C:0x0E3E    F534     MOV      iflag(0x34),A

From above we can see: value in arg2(idata) is copied to DATA memory offset 0x34...

BUT after code merge I got the followings:(quoted from .m51 file)

...
fno = 0x00;iflag=arg2;  // C-code and below is machine code
C:0x0E38    78A1     MOV      R0,#fno(0xA1)
C:0x0E3A    F6       MOV      @R0,A
C:0x0E3B    78AF     MOV      R0,#arg2(0xAF)
C:0x0E3D    E6       MOV      A,@R0
C:0x0E3E    F53E     MOV      0x3E,A

The difference is: value in arg2(idata) is copied to DATA memory 0x3F !
(unfortunately I was asked to not to change this after code-merge...)

Can anyone give comments/breakthrough-point about this ? How can I got the same result as original case after code merge ?

Parents
  • This should be expected behaviour!

    There is absolutely no reason whatsoever to believe that a source-level variable will be fixed at any specific memory address - especially after you have changed the source code!!

    This is the whole point of writing in a High-Level Language (HLL)!

    If it really mattters to you, then you should be writing in assembler - not 'C'.

Reply
  • This should be expected behaviour!

    There is absolutely no reason whatsoever to believe that a source-level variable will be fixed at any specific memory address - especially after you have changed the source code!!

    This is the whole point of writing in a High-Level Language (HLL)!

    If it really mattters to you, then you should be writing in assembler - not 'C'.

Children