> > Thanks. > > So there is no way of initializing it this way but without making it > constant?
You want a variable that has a specific value each time execution starts. What SDCC is doing will give you that semantic *on an embedded device*. SDCC starts off using .ds directives (equiv) and then fills in the values every time just before your application executes. It's nice. > > .com files usually has this information saved in the file itself and when > they are loaded prior to > execution, Yes, if you're loading from disk before each execution, then all you .db and .dw variables will have the startup value you expect. But if you device has no disk, just RAM and ROM, there is no place to "load from". SDCC is "simulating a load from disk" (if you squint your eyes and and perform lots of hand-waving :) ) by copying initial values into global variables (or "static" local variables). You now have a RAM variable that starts at a specific value each time your little program runs! As a thought exercise, what should the value be after a RESET or a power cycle? Whatever the value, should it start off the same? > the variables are already initialized this way. I know I can do > this in assembler, > because I have already done it, and made the variables also global, but > now I intent to do in .c > source file because of some needs. If you run your program only once after download (say in a test lab), then .db and .dw might work. But if you reset the MPU, what value do you expect? If you want a long-lived value that never clears itself, then put a battery on the RAM. HTH, *the other brian > > The only workaround I find is declaring them as external and then create > an asm file that define > them as global and already initialized the way I want, but this is a > little ugly. > > If there is any other idea I would appreciate it. > > Thanks again. > > > ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user