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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/24/09 19:40
Read: times


 
#168523 - Richard has never, ever, in his whole life implemented a bug
Responding to: ???'s previous message
Richard Erlacher said:
Not if the coder is awake! Frankly, I've only occasionally had to deal with negative numbers. It happens some of the time, but it's easy enough to deal with them if one is aware that they are used in a particular context. I guess the reason I don't see them often is because I consider the MCU to be a large and complex piece of hardware rather than a small computer. Either view is valid, I suppose, but I just use it as "just another bit of hardware."

If you write 20k lines of code (quite a small program and well in line with the code space of a 8051 chip), you will have made one or more decisions for each and every line of source. Of course the coder is awake, but lint and similar tools are there because we humans do sometimes makes mistakes. Lint can catch a number of them. If it catches one single error before the application is released, it will most probably have been worth it.

It doesn't matter if you think "small computer" or "another bit of hardware". If you implement some form of regulator, you may have to work with negative values. Your assembler will not help catching an overflow converting a large positive value into a negative value. And an assembler will not think twice about what status flags you will check for in conditional jumps. Saying that we don't need code analyzers because the coder shouldn't sleep is ridiculous. We don't need safety belts in the car either, because the driver should not make a mistake. Or are you willing to tell the world that you have never (!) made a mistake when programming?

Richard said:
If dispatch tables are used, you can easily find where code goes. Symbols are used to identify those entry points, and, in fact, every entry point. The assembler quickly and easily identifies unused labels. Won't that satisfy your need for finding and fixing "unreachable" code. The only possible exception, IMHO, is a branch not taken because an external stimulus doesn't occur. Those sometimes have to be present "just in case."

I can see that you did not spend 5 seconds looking at my example. I showed code that made some form of computation, and used the result of that computation to select the case statement. Good analysis tools could figure out that the formula used in the compuation could have holes - values that are impossible to get. There is no way the assembler will be able to figure out that a computed, complex, expression can never have the result 7, so there is no way the assembler can note that the code following the state_7 jump target is unreachable. Spend time thinking about other peoples arguments, instead using the first second to decide that other people must be wrong!

Richard said:
Richard said:
Type conversions aren't helped by 'C' any more than by ASM. You can stub your toe in either language type.

Any language that doesn't allow you to stub your toe is unsuitable for general embedded programming.

I'm not sure that's true ... PASCAL is one that slaps your wrist when you do something untoward. It has certainly got a substantial following in the embedded community.

And you missed my point again. A HLL can use data type tracking to catch strange type conversions. An assembler can't, because it doesn't have the required type declarations in the first place. The Pascal implementations available will allow you to stub your toe too - they have to, since they have to let you access the SFR and if Pascal doesn't allow you to use pointers to handle conversions between ordinal values and raw bytes most of the type declarations in Pascal would be impossible to use. For embedded, the language has to allow you to do some type casts or direct accesses. But a HLL can limit the percentage of code that is affected - in assembler, every single line is basically affected.

Richar said:
But the type declarations in C allows orders of magnitude better static analysis of the code. The normal C compiler can catch a huge number of problems that an assembler can't know anything about. An assembler thinks a byte is good for 0..255, while a C compiler can note that an enumerator only has values between 0 and 93.

An assembly language program can do that as well. After all, the compiler has to generate assembly language output anyway, doesn't it? The programmer can't go to sleep while coding such procedures, but covering all cases is really important. All that requires is that there's a table entry for each possible state. It doesn't have to transfer control to a unique location for each state.

You are kidding, aren't you?

To the assembler, your registers and memory cells are bytes with the capacity to store 0..255. How can you inform the assembler that a specific variable may never store a value larger than 93? So how would the assembler then be able to analyze your code and catch a bug where you try to increment one time too much? And the assembler may know that something represents a memory address. But it will not be able to know what data type your index register is intended to point at. The HLL compiler can have a pointer to an enumerator, in which case the compiler or external tools can validate that your code don't assign the value 0xff, unless 0xff is part of the enumeration.

I know that you have never looked at tools to analyze source code, or you would not claim that it doesn't matter if you have assembler or C or Pascal code. A HLL adds extra structure, and it is this extra structure that the software analyzers can use to figure out possible problems.

Richard said:
Processing ASCII alphanumeric input, for example, could easily use the same destination for every printable character, except, say, the CR-LF sequence and, probably should treat those two as a special case.

Not sure what your point was. Having printable characters grouped together and individual handling for HT, CR, LF, etc isn't an argument in a datatype discussion, and both assembler or a HLL can either have multiple jumps point at the same target, or have specific tests to find sub-ranges that should be processed identically.

A static analyzer can scan a large state machine and decide that no combination of states can allow the code to reach state 94, so a switch statement having a case 94: can result in an error. Your assembler can't, and I don't think anyone have written a static analyzer that can find such problems in the assembler code. You will have to rely on code coverage tests, and if you find that the state 94 has never been accessed during the test, you will have to manually read the code again to try to figure out if state 94 just is very rare, or if it is actually impossible to reach.

If you have a C or Pascal function set_baud(baud_type baud) where baud is a value 0, 1, 2, 3, ... with the enumration:
enum {
    baud_300,   // 0
    baud_600,   // 1
    baud_1200,  // 2
    baud_2400   // 3
};

a C or Pascal compiler will complain 0=300, 1=600, 2=1200 etc, the C or Pascal compiler will complain if you try to send the value 4. Your assembler will just note that you are sending a one-byte parameter to the function, and will not care if the value sent was 0..3 or something else.

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