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

Unpredicted behiver of code

Hi All,

I'm experiencing a strange behiver in the following flow:

code compiles ok and run ok:
C:000000H C:000000H C:00FFFFH 000935H CODE
I:000000H I:000000H I:0000FFH 000018H IDATA
I:000000H I:000000H I:00007FH 000048H DATA
C:000000H C:000000H C:00FFFFH 0002C0H CONST
X:000000H X:000000H X:00FFFFH 000024H XDATA

Program Size: data=96.0 xdata=36 const=704 code=2357
LX51 RUN COMPLETE. 4 WARNING(S), 0 ERROR(S)

but adding only another char without even code (DATA incress to 49) results with stack problem that RET is jumping to unused address and programs fails.

C:000000H C:000000H C:00FFFFH 000935H CODE
I:000000H I:000000H I:0000FFH 000018H IDATA
I:000000H I:000000H I:00007FH 000049H DATA
C:000000H C:000000H C:00FFFFH 0002C0H CONST
X:000000H X:000000H X:00FFFFH 000024H XDATA

Program Size: data=97.0 xdata=36 const=704 code=2357
LX51 RUN COMPLETE. 4 WARNING(S), 0 ERROR(S)

Can someone tell me what could be wrong ?

Parents
  • The code at first look as a zero mem util.

    That's because zeroing static variables is one of several jobs the startup file has.

    As I wanted to avoid xdata loop calls and save some time

    Doing that will hardly ever save any time. The startup code only loops over XDATA if you use XDATA in your program --- it's clever enough as-is to disable the entire loop if you don't use any XDATA. And unless you're comfortable with your code working with random garbage data, you need to initialize those variables at some point. And whichever way you eventually do that --- it will quite certainly take longer than the way the startup code would have done it.

Reply
  • The code at first look as a zero mem util.

    That's because zeroing static variables is one of several jobs the startup file has.

    As I wanted to avoid xdata loop calls and save some time

    Doing that will hardly ever save any time. The startup code only loops over XDATA if you use XDATA in your program --- it's clever enough as-is to disable the entire loop if you don't use any XDATA. And unless you're comfortable with your code working with random garbage data, you need to initialize those variables at some point. And whichever way you eventually do that --- it will quite certainly take longer than the way the startup code would have done it.

Children
No data