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

c-variable definitions in assembly main

Hi,

I am programming on the Cypress FX2 (8051 compatible) and I have a problem that my variables declared in a c-function do not get initializes properly.

My main program is written in assembly, since I need to have an ISR, which is very short and i want to have full control over what the proc. does during that ISR. I have to include a c-file in my project, which initializes a bunch of registers for a special interface on my USB chip. The problem is that the linker does not include that data segment.

my data is defined this way:

const char xdata WaveData[128] = {128 bytes}

do i need to write an initialization function in C, which moves all that data or is there a way for force the inclusion of that data segment?

thanks,

Greg

ps.: sorry if i am not clear.

Parents
  • "do i need to write an initialization function in C, which moves all that data or is there a way for force the inclusion of that data segment?"

    No, STARTUP.A51 and INIT.A51 contain the C runtime startup code that would normally run first. If you turn your project "inside out", you won't need to do anything special for initialization. By "inside out", I mean configure your project to be a C project with assembly modules, not an assembly project with C modules. This way all the C startup stuff should happen automatically. Have main() simply call your main assembly code when the USB initialization is done. Your main assembly code does not necessarily have to return if everything is done in that code.

Reply
  • "do i need to write an initialization function in C, which moves all that data or is there a way for force the inclusion of that data segment?"

    No, STARTUP.A51 and INIT.A51 contain the C runtime startup code that would normally run first. If you turn your project "inside out", you won't need to do anything special for initialization. By "inside out", I mean configure your project to be a C project with assembly modules, not an assembly project with C modules. This way all the C startup stuff should happen automatically. Have main() simply call your main assembly code when the USB initialization is done. Your main assembly code does not necessarily have to return if everything is done in that code.

Children
No data