Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/17/09 07:52
Read: times


 
#166172 - Versatility and diversification
Responding to: ???'s previous message
You are still living in the 8-bit world. An embedded unit may have the capacity of a 100MHz i486 PC. If it already has a working Linux kernel, then it is quite likely that any code that needs to be written can be in C or C++ - even any new drivers required.

Next thing. If you need nanosecond delays between signal transitions, and know the existence of a __nop() intrinsic, you can manage a "at least long enough" loop without knowing more than the execution time of a nop instruction for the relevant processor. For longer delays, it is likely that you can use us-resolution delays already available in the kernel. Using hw timers or similar obviously does not require assembler knowledge to use.

Next step up - writing efficient C code requires a basic knowledge of what makes the processor tick - it does not require the knowledge to be able to write assembler code for that processor.

You still have to get out of your box and realize that the embedded world spans a huge range of target hardware, and that the requirements varies quite a lot dependong on where a specific product exists on this scale - both in type of hardware, and in production volume and in cost requirements.

You may take your 8051 10MIPS 8-bit processor and fit it with a bar-code reader containing a 32-bit 100+ MIPS processor. Or maybe connect it to a GPRS module with a 400MIPS processor having 32MB flash + 32MB of RAM. That GPRS module is also running embedded software, but developed under different requirements than your 8051 code. Or you may have a multimedia box having a GB of RAM and flash, and used with TB-sized disks.

So the company developed a multimedia box with a MIPS processor and then decides to switch to an ARM or a PPC or x86. You port the Linux kernel and recompiles the software and runs it on the new hardware. Then you decide that the developers who wrote the code should have o leave the company and be replaced with other developers because they don¨t know how to write in assembler for the new processor? That is basically your view - they wouldn't be competent unless they happened to know how to develop in assembler for the new processor (and I have to assume that you mean write really good assembler, and not just be able to scribble something that sneaks past the assembler).

The question I have to ask is of course how many bigger processors you know how to write efficient assembler for? being a competent assembler programmer for a small PIC, 8051 or AVR processor is quite easy compared to learning how to write efficient assembler code for some of the bigger 32-bit processors. In a world where you may need to produce a new model of a product every 6 months, you may have a situation where the assembler code is seen as bad programming - representing big costs to the company since you can't just recompile for a new target hardware.

In the end, it is vital to realize that the metrics to measure competence or code quality must be defined on a case-by-case basis. It isn't possible to live in a one-size-fits-all world. While an embedded developer should be very familiar with the instruction set for a number of different processor architectures, there will be many situations where there will be no need to know how to write in assembler for a specific processor.

Your delay loop example? locking down the code generated by the C compiler can be as simple as having the C compiler produce an assembler listing, and rip the assembler output and modify to a stand-alone assembler function. The C-generated code may possibly consume one or two instructions extra compared to hand-optimized code, but if the target hardware happens to have MB of flash, that would probably be irrelevant. If you need an extra byte at a later time, you would probably have 10 or 100 thousand lines of C code that would be quicker to look at for squeezing out that required byte.

I have situations where I have spent a day writing an optimized assembler routine for a time-critical function. Then spent 4 hours writing and testing 10 different variants in C and had 3 of the C implementations run within 3% of the time of my assembler code. For posterity, I could commit the assembler code just to have a backup of it. Then directly change the application to use the most readable/maintainable of the three fastest C alternatives. That C code may not have been the fastest alternative if moving the code to another processor, but it would be at least reasonably efficient, and it will compile. And after a platform change, the processor may possibly be changed to one where the code runs several times faster than needed, allowing basically zero maintainance cost for moving the code.

In the end, I would be a lousy embedded developer if I run around thinking that assembler is the big goal. That would be similar to having a hammer and thinking everything looks like a nail.

List of 95 messages in thread
TopicAuthorDate
What's wrong with gimme code?            01/01/70 00:00      
   Mainly            01/01/70 00:00      
      I agree with Jez Smith            01/01/70 00:00      
         Non academic gimme code?            01/01/70 00:00      
            This makes me very suspicious            01/01/70 00:00      
            gimme code=my own time is too valuable            01/01/70 00:00      
               Easy to see which is school assignment            01/01/70 00:00      
                  The wise student needs pointers, not complete solutions            01/01/70 00:00      
            "Here's what I've come up with ...            01/01/70 00:00      
               But what's wrong in asking for an example implementaton?            01/01/70 00:00      
                  The teacher recognises the good student            01/01/70 00:00      
                     Now there's a laugh if ever there was one ...            01/01/70 00:00      
                  nothing IF ...            01/01/70 00:00      
            children should do their own homework            01/01/70 00:00      
   What's wrong with gimmee code.            01/01/70 00:00      
   Sounds Like; Whats wrong with Spoon Feeding..?            01/01/70 00:00      
      perhaps it enables ...            01/01/70 00:00      
         Generic solutions applicable to more people            01/01/70 00:00      
         Then they'll become expert at potty ...            01/01/70 00:00      
   it makes you dumb!            01/01/70 00:00      
   How'd you like ten of those guys working for you?            01/01/70 00:00      
      But that's the point!            01/01/70 00:00      
         We agree in principle, Kai ... but ...            01/01/70 00:00      
         Hiring & firing is expensive!            01/01/70 00:00      
            and that's not all!            01/01/70 00:00      
   As an example            01/01/70 00:00      
      No-one is suggesting breach of copyright            01/01/70 00:00      
         arrogance?            01/01/70 00:00      
            Examples of Erik's arrogance            01/01/70 00:00      
               no, I do not state any such,            01/01/70 00:00      
                   A couple of corrections            01/01/70 00:00      
                     more useful product?            01/01/70 00:00      
         life is not B&W            01/01/70 00:00      
            Good help _is_ to a big part to give hints            01/01/70 00:00      
               Votes and freedom of speech?            01/01/70 00:00      
               When I was a youngster ...            01/01/70 00:00      
                  Returning to the original subject.            01/01/70 00:00      
                     same same but sometimes different            01/01/70 00:00      
                     Since you like AVRFREAKS so much ...            01/01/70 00:00      
                  Versatility and diversification            01/01/70 00:00      
                     This is 8052.COM            01/01/70 00:00      
                  and.....            01/01/70 00:00      
         There's always help for those who can do their own work.            01/01/70 00:00      
            There's the key!            01/01/70 00:00      
         that is not the issue            01/01/70 00:00      
            I'm with you 100% on that, Erik            01/01/70 00:00      
               calm down Richard            01/01/70 00:00      
                  support for more MCU's makes it more widely useful            01/01/70 00:00      
                     it?            01/01/70 00:00      
                        Which MCU's will KEIL support?            01/01/70 00:00      
                           Irrelevant            01/01/70 00:00      
                              Keil's blind spot            01/01/70 00:00      
                                 Keil will probably get squeezed            01/01/70 00:00      
                              If only that were the case            01/01/70 00:00      
                                 Portable 'C' [edited]            01/01/70 00:00      
                                 Write what you mean or mean what you write            01/01/70 00:00      
                                    OK ... Here's the point            01/01/70 00:00      
                                       If bugs is a big problem - consider your compiler choices            01/01/70 00:00      
                                 C is not that difficult            01/01/70 00:00      
                                    I can't totally disagree ... it's a matter of degree            01/01/70 00:00      
                                    Richard misses the point completely            01/01/70 00:00      
                  The thing is...            01/01/70 00:00      
                     I don't think thats true at all            01/01/70 00:00      
                        Not what I meant            01/01/70 00:00      
                           Andy's right!            01/01/70 00:00      
         elders and betters would have given a helpful reply.            01/01/70 00:00      
   If you think 8052.com is bad ...            01/01/70 00:00      
   When was it the last time someone asked for code?            01/01/70 00:00      
      oohhh            01/01/70 00:00      
      Here?            01/01/70 00:00      
      Latest example of "Gimme Code"            01/01/70 00:00      
   What the forums are all about            01/01/70 00:00      
      Progress            01/01/70 00:00      
         No, don't agree with "exhausted all the possibilities"            01/01/70 00:00      
            patience            01/01/70 00:00      
         inexperienced            01/01/70 00:00      
            Well actually...            01/01/70 00:00      
               you must have a very smart wife            01/01/70 00:00      
                  If you're a friend ;-)            01/01/70 00:00      
      arrogant?            01/01/70 00:00      
         encouragement            01/01/70 00:00      
            absolutely            01/01/70 00:00      
            What you have to remember            01/01/70 00:00      
               Tim Berners-Lee            01/01/70 00:00      
                  he only invented the web thingy            01/01/70 00:00      
                     Exhausted all the possibilities...            01/01/70 00:00      
                        this is just not fair            01/01/70 00:00      
                           It's about attitude            01/01/70 00:00      
                              on intentions etc.            01/01/70 00:00      
                              98% of 100            01/01/70 00:00      
                           good and bad            01/01/70 00:00      
      OK Charles (et al), here's your chance!            01/01/70 00:00      
         re: OK Charles here's your chance            01/01/70 00:00      
            QED.            01/01/70 00:00      
            Yet one more exhausted visitor            01/01/70 00:00      

Back to Subject List