On Thu, 2007-05-31 at 17:01 -0500, Mike McCarty wrote: > Andy Green wrote: > > Mike McCarty wrote: > > > >>Andy Green wrote: > >> > >>>Mike McCarty wrote: > >> > >>[snip] > >> > >> > >>>>C doesn't initialize what? It initializes all used variables. > >>> > >>> > >>>Not if they're on the stack. You should get a compiler warning > >>>nowadays... but don't count on it! > >> > >>Erm, C knows nothing about a "stack". However, it is true > >>that automatic variable are not necessarily initialized. > >>I should have stated that all statically allocated variables > >>are initialized. Thanks for the correction. > > > > > > You're welcome. > > > > I think you have to draw a line between the glorious worlds of > > possibility left open by the wording of the standard and the grimy > > reality of the actual compilers. "Automatic variables" will be > > allocated off the stack frame on any actual compiler that is worth the name. > > I wonder what you mean by "any actual compiler that is worth > the name". The 8051 normally uses no stack at all. Uh, I probably shouldn't re-enter this discussion, but I'll throw caution to the winds and put on my fire suit... While a language such as C is useful on things such as 8051s, it was really designed for general purpose computers. I don't think I'd call an 8051 a "general purpose" processor. IIRC it's a really nice microcontroller--very useful for physical process control and the like along with many other processors of its ilk. My memory on those sorts of things is a big fuzzy, I'll admit. > > Though back in the day I did read about a C "compiler" for a tragic arch > > that neither had a stack nor more than 256 bytes of RAM IIRC... it > > disallowed recursion or more than 2 function call depth... other than > > that I propose any compiler will be using a stack frame whether the word > > is in the standard or not ;-) > > The 8051 has Harvard architecture, giving it 64K of data space and 64K > of program space. But it has no real stack, so compilers for it normally > don't implement one unless specifically requested so to do. Doing so > causes a significant execution penalty. There are LOTS of 8051s (and > its progeny) out there. I don't doubt that. I worked with it and its sire, the famous 8048 (ah, a processor with a built-in UVEPROM), their grandfather (the 8008) and their great-grandfather (the 4004). I've done bitslice stuff, too. That was long, long ago in a computer lab far, far away. One of my favorite old minis was the HP 2100/21MX series. It had a stack, but the first instruction of any subroutine had to be a no-op instruction as that's where the processor stuck the return address of the calling routine. Compilers made that reasonably easy, but back in the day of coding via assembly, you always had to remember that your subroutine had to start with: label: nop Lots of weird stuff happened when you forgot to do that. I remember blowing up a pretty damned expensive servo once when I forgot. Life was, uh, interesting back then (late 70s). And no, I didn't "disco". ---------------------------------------------------------------------- - Rick Stevens, Principal Engineer rstevens@xxxxxxxxxxxx - - VitalStream, Inc. http://www.vitalstream.com - - - - Change is inevitable, except from a vending machine. - ----------------------------------------------------------------------