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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/18/09 16:26
Read: times


 
#168380 - apples to pears?
Responding to: ???'s previous message
Richard said:
I can say that because much of the code I've worked on was written in ASM 20-30 years ago and the product is still in operation being used as intended, and simply required a bit of upgrading to add or support additional equipment or features.

Maybe not so relevant. The question is: Do you have recent knowledge from extensive work in both assembler and C? To compare an apple to a pear, you need similar experiences with both.

Richard said:
I've spent plenty of time with HLL's, just don't use HLL with micro-controllers.

The question is: Do you have recent, extensive, knowledge of doing similar things in both C and assembler? If you do one type of program in C and another type of program in assembler, you will not compare the same thing. When doing a bread-and-butter administrative tool, I may produce 1k+ lines/day of C code for day after day. If implementing a highly efficient search routine for geographic data, I may produce 100 lines/day. When working with some problems, the complexities of the problem may mean I only averages 10 lines/day.

So when comparing how efficient I am when using C or assembler, I have to compare when doing similar things. How efficient am I decoding NMEA data from a GPS when using assembler or C? If I haven't a big set of similar problems I have worked with using different tools, it will be very hard to estimate the productivity.

In your case, you don't seem to use any C compiler for 8051 work. But you claim you have done a lot of C programming of old MS-DOS applications using Turbo C.

Richard said:
It's just like instantiating a function. It's not just copy-and-paste, though folks who've never used a macro-assembler wouldn't know that.

I think most people here do know what a macro assembler is. But the instantiation of a macro is basically a paste of a fixed expansion, combined with a search/replace depending on supplied arguments. When implementing more comples logic (the kind when documentation, testing etc really matter), you will get little use of macros, because so few assembler source lines will match any pre-written macro.

Richard said:
Per Westermark said:
The C compiler is not comparable to a strange macro assembler, where a C expression will map to a fixed code expansion.

What do you mean by "strange" macro-assembler? Do you simply mean one with which you're not familiar? Isn't it the same when you switch compilers?

For someone who don't know how a C compiler works, it is easy to think of it as a macro assembler. a=a+1 can be seen as the instatiation of the macro INCREMENT_WITH_ONE(a).

The important thing here is that the existence of a large number of assembler macros may be nice. But when solving real problems, the parts of the code that will take time will not match any pre-cooked macros, so the assembler programmer will have to spend significant time trying to figure out what registers to use to manage an efficient solution. And when the complexity of the problem is high, it is quite likely that the developer will have to modify the code a lot until reaching a good solution. Rewriting the C code is way faster than rewriting the assembler code. And the rewriting need not be caused by a bad developer, but because you need to make a lot of test runs to find out the exact behaviour of the system you are going to control. In some situations, you may tune constants. But in some situations, you will have to make changes to the algorithms depending on the feedback you get from test cases.

Richard said:
So you believe that moving from an 805x to a M68-something or a PIC would simply be a matter of plugging the same code into a different compiler? I guarantee you that wouldn't be so easy if you've used Keil's product.

I think you are the only one who believes I am making such a claim. But a significant percentage of a C application is possible to move from a 8051 to a PIC or AVR with very minor changes. The business logic of an application isn't so much affected by what processor you have. I know because I have moved code between processor architectures many times. Whenever I do write new code, I know one thing: I don't know if I write the code for the final processor, or if the code may jump. I have even regularly moved code for 8-bit processors to 32-bit machines to let the build machine test significant parts of the code in a simulated environment. The only real language issues when moving Keil C51 code to another compiler is the bit variables. But it is not a big job to get the code to compile on a processor that doesn't have bit variables if I can live with each variable expanding from a single bit to a byte. And with use of #define, I can use TEST_XX, SET_XX, CLEAR_XX in the code, and compile the code to directly use a bit variable or set/reset/test a specific bit in a byte.

If I can move the business logic from one processor to another, and then merge the business logic with copy/paste code for the timers, UART etc from other applications already using the new architecture, I can get very significant code reuse when moving an application between processors. Even when there are big differences in architecture.

I would not like to produce the same hw for 20-30 years, desperately buying surplus batches of old processors just because the cost is too high to switch to newer processors.

Richard said:
Don't forget the microcontroller task:

Examine inputs (including current context) and take appropriate action.

But the controlling part can be quite complex. And when a system is non-linear, or you have unknown constants, it may not be applicable to use lookup tables.

Richard said:
What simpler method than table-lookup could there be?

It may be simple, but only capable of handling a subset of problems without exploding to infinite size. And if the customer is allowed to configure the behaviour, you may have to build the tables dynamically and store in way more expensive RAM. And if the system is non-trivial, you would normally not build your tables by hand, but instead use software to generate them.

List of 131 messages in thread
TopicAuthorDate
Article: "Real engineers program in C"            01/01/70 00:00      
   C and Latin            01/01/70 00:00      
      similarities between English and C            01/01/70 00:00      
         all sorts of similarities            01/01/70 00:00      
      NOT engineers.....            01/01/70 00:00      
         I think that was his point?            01/01/70 00:00      
            I know            01/01/70 00:00      
               I also don't know if his diagram on Page 3 is right            01/01/70 00:00      
   fewer ASM developers            01/01/70 00:00      
   languages            01/01/70 00:00      
   Muscle Vs Fat            01/01/70 00:00      
      apples vs bears            01/01/70 00:00      
         Wait a minute, pilgrim!            01/01/70 00:00      
            pilgrim has arrived            01/01/70 00:00      
            Break out that DOS Computer            01/01/70 00:00      
               I do that quite often!            01/01/70 00:00      
            blame drivers            01/01/70 00:00      
               Equip them right and they seem to work ... sort-of            01/01/70 00:00      
                  Engineers and Marketing guys            01/01/70 00:00      
            jeeziz x kryst            01/01/70 00:00      
               So ... Why do you do all that?            01/01/70 00:00      
                  wrong choice of word            01/01/70 00:00      
                     It's just a millstone ...            01/01/70 00:00      
                  re: why?            01/01/70 00:00      
      My computer _boots_ faster than that.            01/01/70 00:00      
         DMA?            01/01/70 00:00      
      Maybe it's the amount of memory            01/01/70 00:00      
         The cost of mutlitasking..            01/01/70 00:00      
         haven't any time to waste            01/01/70 00:00      
            That would be too slow!            01/01/70 00:00      
               I see no ships!            01/01/70 00:00      
               Isn't 4k plenty for a '51?            01/01/70 00:00      
                  which '51 does have that?            01/01/70 00:00      
                     Erik would call those "deviates".            01/01/70 00:00      
                        nope            01/01/70 00:00      
                        pipelines, cars, and real engineers            01/01/70 00:00      
                           It's also pipelined.            01/01/70 00:00      
                              then it's irrelevant            01/01/70 00:00      
                  If you can ignore those features            01/01/70 00:00      
               keeping up            01/01/70 00:00      
                  I feel your pain ...            01/01/70 00:00      
                     Don't see problems - see possibilities            01/01/70 00:00      
                        Do you really want to hide from reality?            01/01/70 00:00      
                           Always hiding behind excuses            01/01/70 00:00      
                              What excuses?            01/01/70 00:00      
                                 Your excuses            01/01/70 00:00      
                                    Do you directly or indirectly work for Keil?            01/01/70 00:00      
                                       BULL!!            01/01/70 00:00      
                                          I don't harbor any animosity, but I don't like being lied-to            01/01/70 00:00      
                                             you "understand well enough"            01/01/70 00:00      
                                                I have to agree ... evaluation takes time ...            01/01/70 00:00      
                                                   this is where I think I'm the realist            01/01/70 00:00      
                                                      If only the pieces were separately available ...            01/01/70 00:00      
                                                         I can't and would never            01/01/70 00:00      
                                                            So ... Who's a simulator specialist?            01/01/70 00:00      
                                                               don't know, don't care            01/01/70 00:00      
                                                                  So why even mention it?            01/01/70 00:00      
                                                                     because someone (you?) brought it up            01/01/70 00:00      
                                       Tangential Richard at work            01/01/70 00:00      
                           the pot calling the kettle black            01/01/70 00:00      
                     that's the crux            01/01/70 00:00      
                        It's a matter of realism            01/01/70 00:00      
                           well, if you do not have the time to evaluate, your points            01/01/70 00:00      
                              I have to disagree ...            01/01/70 00:00      
                                 no need            01/01/70 00:00      
                                    That would be an ideal fix!            01/01/70 00:00      
                  no way            01/01/70 00:00      
                     but only if we both define a project            01/01/70 00:00      
                        oh, that's no proof then...            01/01/70 00:00      
                           It would be a nice idea, but how would you time it?            01/01/70 00:00      
                           you did not read what I said            01/01/70 00:00      
                              implication and how to challenge it            01/01/70 00:00      
                                 disassembly            01/01/70 00:00      
                                    Encryption module?            01/01/70 00:00      
                                    not at all            01/01/70 00:00      
                                       It's clear to see that some folks really like 'C'            01/01/70 00:00      
                                          can you only like one thing?            01/01/70 00:00      
                                             Yes, but ...            01/01/70 00:00      
                                                you can boil steak too            01/01/70 00:00      
                                                   but you don't have to do that            01/01/70 00:00      
                                                      but you just said            01/01/70 00:00      
                                       no praise, just not hate            01/01/70 00:00      
                                          That makes sense            01/01/70 00:00      
                                          not that claim            01/01/70 00:00      
                                             again you miss 'usually', 'mostly', 'often', etc            01/01/70 00:00      
                                                Not so ... exactly            01/01/70 00:00      
                                                   Based on what experience?            01/01/70 00:00      
                                                      That's not how it works            01/01/70 00:00      
                                                         maintenance is a totally different issue            01/01/70 00:00      
                                                         apples to pears?            01/01/70 00:00      
                                                            I don't need to compare/contrast apples and pears            01/01/70 00:00      
                                                               The embedded world is larger than your tiny island            01/01/70 00:00      
                                                   IF            01/01/70 00:00      
                                                      It's all about initial hardware cost, not maintenance cost.            01/01/70 00:00      
                                                         Value of investment            01/01/70 00:00      
                                                         Not Here            01/01/70 00:00      
                                                         Whose business?            01/01/70 00:00      
                                                            What do you mean by "code analysis tools"?            01/01/70 00:00      
                                                               Some important tests            01/01/70 00:00      
                                                                  Yes, those come up in HLL, but ...            01/01/70 00:00      
                                                                     Memory leaks nothing to do with HLL            01/01/70 00:00      
                                                                        Yeah, you can do that ... but it's not recommended            01/01/70 00:00      
                                                                           More way than one to create memory leaks            01/01/70 00:00      
                                                                           that is not applicable to small embedded            01/01/70 00:00      
                                                                     Way easier to analyse non-goto code            01/01/70 00:00      
                                                                        and why would that be?            01/01/70 00:00      
                                                                           General purpose languages normally allows dangers            01/01/70 00:00      
                                                                              You still don't get the point, Per            01/01/70 00:00      
                                                                                 Wrong question            01/01/70 00:00      
                                                                                    what view?            01/01/70 00:00      
                                                                                       and the answer is            01/01/70 00:00      
                                                                                       can be seen as a leading question            01/01/70 00:00      
                                                                        Careful now! Some folks like Pascal for the '51            01/01/70 00:00      
                                                                           Why?            01/01/70 00:00      
                                                                        Some things depend on your point of view            01/01/70 00:00      
                                                                           Richard has never, ever, in his whole life implemented a bug            01/01/70 00:00      
                                                                              I may have written 'em, but I've never shipped 'em            01/01/70 00:00      
                                                               QAC and Polyspace            01/01/70 00:00      
                                                                  thanks, Oliver            01/01/70 00:00      
                                                                     MISRA and assembly don't mix well.            01/01/70 00:00      
                                                                        you can write FORTRAN in any language            01/01/70 00:00      
                                                                           I know ... but MISRA rules are explicit.            01/01/70 00:00      
                                                                              Not happy will all parts of MISRA            01/01/70 00:00      
                                                                                 Interesting discussion of MISRA C:            01/01/70 00:00      
                                                                                 Flawed but useful            01/01/70 00:00      
                                                                              Nested comments can produce different results            01/01/70 00:00      
                                                                           That's the thing with rules            01/01/70 00:00      
                                                                     Polyspace            01/01/70 00:00      
            Also in VB            01/01/70 00:00      
               Amazing!            01/01/70 00:00      
   You really are very naughty Andy            01/01/70 00:00      

Back to Subject List