Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | 68HC12 | CW mixed C and assembly static variables


Advertise Here

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

CW mixed C and assembly static variables - Michael Huslig - Oct 7 11:25:00 2004

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






(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )


Re: CW mixed C and assembly static variables - MW Ron - Oct 8 10:48:00 2004

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




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

Re: CW mixed C and assembly static variables - Daniel Friederich - Oct 8 11:09:00 2004

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




(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )

RE: CW mixed C and assembly static variables - Erich Styger - Oct 8 15:25:00 2004

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





(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )