Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).
|
Does anyone know how to generate a C-type static variable in an assembly file. I tried the following, but the code is not showing up in the copydown section COPY, as determined by the .prm file. Non-zero static variables in the .c files do show up in the COPY section. DEFAULT_RAM: section mystaticvar: ds.b 1 COPY: section dc.w 1 ;size dc.w mystaticvar ;pointer dc.b 1 ;value Mike |
|
|
|
Michael Huslig wrote:
> Does anyone know how to generate a C-type static variable in an assembly > file. I tried the following, but the code is not showing up in the copydown > section COPY, as determined by the .prm file. Non-zero static variables in > the .c files do show up in the COPY section. > DEFAULT_RAM: section > mystaticvar: ds.b 1 > > COPY: section > dc.w 1 ;size > dc.w mystaticvar ;pointer > dc.b 1 ;value The CodeWarrior tools should come with a tech note on mixing C and Assembly TN15.pdf If don't have the CD or you didn't download them, you can download them separately http://www.metrowerks.com/pdf/816bit/MCUQA_TechNotes.zip Ron -- Metrowerks Community Forum is a free online resource for developers to discuss CodeWarrior topics with other users and Metrowerks' staff -- http://www.metrowerks.com/community -- Ron Liechty - - http://www.metrowerks.com |
|
Michael, If I do understand your question correctly, you want to know how to write in an assembly file variables which will be initialized by the startup code of the compiler. Your approach does not work as the .copy section is generated by the linker, not by the compiler. Actually it's much simpler, just let the linker do the hard work. Here is how for your example: ASM_RAM: section mystaticvar: DC.B 1 ;value And in addition do explicitly list ASM_RAM in a READ_WRITE placement in the prm file. With this setup, the linker detects that there is initialization data for the variable mystaticvar and the linker will generate the correct .copy section content. As additional hint, put all your initialized variables are in a separate section than the non initialized variables. Mixing DS with DC's in a single section will end up with an initialized section. Bye Daniel Michael Huslig wrote: >Does anyone know how to generate a C-type static variable in an assembly >file. I tried the following, but the code is not showing up in the copydown >section COPY, as determined by the .prm file. Non-zero static variables in >the .c files do show up in the COPY section. >DEFAULT_RAM: section >mystaticvar: ds.b 1 > >COPY: section > dc.w 1 ;size > dc.w mystaticvar ;pointer > dc.b 1 ;value > >Mike > > >Yahoo! Groups Links |
|
Did you search in the generated .map file for your mystaticvar? Maybe it is listed under NOT USED VARIABLES If yes, make sure that you use your mystaticvar in your code. Alternatively you can use ENTRIES ... END in the prm file as well (see the linker manual). But from what I see below you want to pass somehow size and initalisation value to the linker? I don't think that this would work, so you would have to do the initialisation yourself? Then I suggest that you create your own 'init' function in assembly, where you initialize your variables. Erich > -----Original Message----- > From: Michael Huslig [mailto:] > Sent: Donnerstag, 7. Oktober 2004 12:25 > To: > Subject: [68HC12] CW mixed C and assembly static variables > > Does anyone know how to generate a C-type static variable in > an assembly > file. I tried the following, but the code is not showing up > in the copydown > section COPY, as determined by the .prm file. Non-zero > static variables in > the .c files do show up in the COPY section. > DEFAULT_RAM: section > mystaticvar: ds.b 1 > > COPY: section > dc.w 1 ;size > dc.w mystaticvar ;pointer > dc.b 1 ;value > > Mike > ------------------------ Yahoo! Groups Sponsor > --------------------~--> > $9.95 domain names from Yahoo!. Register anything. > http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/dN_tlB/TM > -------------------------------------------------------------- > ------~- > Yahoo! Groups Links |