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

Removing INIT.A51 file

I am facing an issue with initialization. I created a project with uVision3. I modified standard start up file STARTUP.A51 for my application as below:

?C_C51STARTUP   SEGMENT   CODE
?STACK          SEGMENT   IDATA

                RSEG    ?STACK
                DS      1

                EXTRN CODE (my_main)
                ;EXTRN CODE (?C_START)  ;--- commented ?C_START


                ;.........Standard Code.......

IF PBPSTACK <> 0
EXTRN DATA (?C_PBP)
                MOV     ?C_PBP,#LOW PBPSTACKTOP
ENDIF

                MOV     SP,#?STACK-1

                ;LJMP   ?C_START  ;--- commented jump to ?C_START
                LJMP my_main

NOTE: my_main is a starting function defined in my project.

I am including this modified file in my project. Also i am not including INIT.A51. With this i am facing an issue in my code. Whenever i initialized global data, program wont take it. For example, if i initialized below global variable:

unsigned char counter = 5;

When in code i checked counter value, it is always 0x00. I think this is problem with not calling ?C_START which is defined in INIT.A51. Due to this, all global initialisation is not happening.

Is this correct ? Is there any way to avoid this issue (apart from including INIT.A51)? Can anyone tell me which part of the INIT.A51 file i can copy to STARTUP.A51 before below code


                ;LJMP   ?C_START  ;--- commented jump to ?C_START
                LJMP my_main

so that i cant have this issue ?

Thanks in advance !!

Parents
  • "Can anyone tell me which part of the INIT.A51 file i can copy to STARTUP.A51 [...]"

    The solution is simple. If you want your C code (and the CRTL) to see a normalized environment, you have to run all the required initialization functions.

    If you don't know what code that must be run, then you also don't know what code to remove. So removing startup code would then be out of the scope.

    So why then, when you don't have a 100% knowledge of the basic foundations for the C code to function, have you decided to cut out parts of the initialization code? What are you trying to solve that makes you think it is practical to first put out a ring of fires on the ice and then sit in the middle trying to catch some fish, while the ice is quickly melting all around you?

    There is a programming paradigm KISS - Keep It Simple Stupid. It basically says that we should always try the simplest solutions to problems first, to avoid overcomplicating things. What huge problem do you need to solve that makes you reach directly for the big hammer?

Reply
  • "Can anyone tell me which part of the INIT.A51 file i can copy to STARTUP.A51 [...]"

    The solution is simple. If you want your C code (and the CRTL) to see a normalized environment, you have to run all the required initialization functions.

    If you don't know what code that must be run, then you also don't know what code to remove. So removing startup code would then be out of the scope.

    So why then, when you don't have a 100% knowledge of the basic foundations for the C code to function, have you decided to cut out parts of the initialization code? What are you trying to solve that makes you think it is practical to first put out a ring of fires on the ice and then sit in the middle trying to catch some fish, while the ice is quickly melting all around you?

    There is a programming paradigm KISS - Keep It Simple Stupid. It basically says that we should always try the simplest solutions to problems first, to avoid overcomplicating things. What huge problem do you need to solve that makes you reach directly for the big hammer?

Children
No data