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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/04/09 22:56
Read: times


 
#163075 - We will have to agree to disagree ... I guess
Responding to: ???'s previous message
Per Westermark said:
...

First off: You are basically saying that C developers are quite stupid. Such a claim only falls back on yourself. Don't assume that people who do other things or uses other tools than you are not clever and professional and open-minded... Maybe you do see failed projects and have to make them work. But in that case you have to remember that you will not see the working projects.

That's not what I said, nor is it what I believe. However, this forum provides ample demonstration that SOME 'C'-programmers are way past "quite" stupid, and, in fact are not only totally stupid but abysmally lazy, too.

But this isn't a question of PC or microcontroller. The question is: Have you spent time looking at the generated code for the biggest/best compilers on the market? They just happen to not include any 8051 compiler, since there isn't market enough to invest millions of dollars in a 8051 compiler. But have you looked at the code generated by the ARM compiler? I definitely think that it produces sensible code.

I've not spent much time at that, simply because that doesn't matter much to me. I've spent time communicating with the sales and the support people associated with various compilers for various MCU's, and concluded that it's not worth risking even a single dollar on their products. I did buy one C-51 compiler years ago, but won't do that again anytime soon.

I have spent time looking at ARM output for time critical sections. I have also written my own assembler code. I have been able to win on instruction counts on several occasions. But I may not have won on cycle count, because the compiler can rearrange the instructions in ways that is hard to do for me without losing track of the contents in the registers - unless I document the source in ways that the next developer will shoot me.

I've no doubt that compilers for ARM, MIPS, and other similar type and size computing engines execute code generated by compilers do that very well. They were, after all, designed with the compiler in mind. The X86, of which I'm not particularly fond, was designed a decade earlier at at time when 'C' was not so widely used. In the '80's most colleges were still teaching PASCAL as the primary instruction language. Some were even teaching BASIC, which is really not a modern language at all.

Right now, you are programming a 8051 chip. It is one of the simplest processors in the world to program by hand in assembler. It is one of the least suitable processors for a HLL language.

That's why I advocate in favor of ASM rather than 'C' for use with the 805x core.

If you look at many of the newer architectures - where the transistor count wasn't important in the design - you will note the reverse. They are designed to be easy to implement compilers for but can be extremely hard to program for a human being who can't keep 20 or 50 or 500 facts in the head at the same time. I'm ok with moving a few individual assembler instructions two or three steps up or down in the code, to optimize access patterns but that is my limit. I can't keep track of 20 or 50 instructions that are moved +/- 20 steps up or down or more.

I think you are condemning compilers based on experience with small compilers maintained by maybe 1 or 2 developers, totally missing the advances there have been in code quality for the best compilers. You are always free to have any opinion you like, but be careful in underestimating things.

The world where you can count individual clock cycles in your loop is quickly shrinking because of the additions of caches, out-of-order execution, extra shadow registers, ...


Microcomputers and, ultimately, microcontrollers, evolved as a substitute for large amounts of logic IC's. 805x's are relatively simple when compared to the entire spectrum of computers, but quite "up there" considering when they were developed. Yes, they've evolved somewhat, mostly in the amount of on-chip memory can be contained within a single IC, and, to lesser extent, the peripherals that can be incorporated in the core. The current trend may ultimately lead to 805x's with a full complement of both code and data memory on the chip. I doubt that will ever happen with ARM or other 32-bit RISC's, not that the technology won't eventually allow it. 805x's can executed code at a pretty good clip without caches and other features that make cycle counting practical. Until ARM and other such cores make precise timing of code execution, they'll never suit all applications, since some will always require what the 'C' compiler can't be relied-upon to produce, namely precisely timed code execution. Now, one can determine, empirically, how long a given compiled code segment takes to execute, but if one changes even one minor feature, e.g. location in memory, the timing can suffer severe impact.

I primarily use microcontrollers as a substitute for discrete, or programmable, logic. They're not computing engines from where I sit, but, rather, they're ways of generating, routing, and switching signals.

I have, at times, considered using a compiler to generate macros that I can use in code written in ASM. By that I mean that there often are small code segments that are non-critical in their timing. The compilers don't make this particularly convenient, however.

ARM jealously retains the rights to their core, while MIPS is available in several open-source versions in VHDL or in Verilog. This makes MIPS, which is supported as well as ARM and on which LINUX is just as happy to run, a more attractive option for integration into programmable logic and, ultimately, into ASIC. I've always liked the ARM as a microcomputer core, since it is cheap, can be fast, and is well supported with open-source tools. However, I don't consider it viable as a microcontroller core for tasks not explicitly supported by on-board peripherals, since it's difficult to program in ASM, as you've pointed out.

About that documentation ... A successor should be able to read the documentation and, from that alone, fully understand every detail of what the system does, without even looking at one line of code. Further, it should be absolutely clear when reading the code listing, why each and every clause has the syntax that it has, based on the system requirements. If it doesn't do that, then it is simply not properly documented. That's MUCH easier to do in ASM than in a high-level language. If the documentation and listings don't make everything crystal-clear, then it's likely the reader isn't sufficiently familiar with the instruction set and instruction timing.

As for the "religious" issue ... I guess we'll have to agree to disagree. I can understand the desirability of using a small ARM-core single-chip microcomputer, but by its very central characteristics, it differs considerably from the classic microcontroller. Further, for its cost, ARM can't well compete with the performance of current-generation 805x one-clockers. That may change, of course, but I won't hold my breath.

RE



List of 76 messages in thread
TopicAuthorDate
NXP P89LPC936 Auxilary RAM            01/01/70 00:00      
   Compiler Cannot Save the Day At Runtime            01/01/70 00:00      
      I found it.....            01/01/70 00:00      
         Incorrect!            01/01/70 00:00      
            To be fair,...            01/01/70 00:00      
               Its good info to know...            01/01/70 00:00      
   how is it done in C?            01/01/70 00:00      
   Maybe you should try doing it ASM!            01/01/70 00:00      
      You should start a new thread on that!            01/01/70 00:00      
      Not in this case!            01/01/70 00:00      
         A compiler should support ALL MCU features ...            01/01/70 00:00      
            A compiler should translate the language            01/01/70 00:00      
               Still C - just not strict.            01/01/70 00:00      
            I didn't say that!            01/01/70 00:00      
               It is not that clean and clear            01/01/70 00:00      
                  Deviants are deviant            01/01/70 00:00      
                     Keil and SDCC need no macros ...            01/01/70 00:00      
                        Are you sure?            01/01/70 00:00      
                     That's probably correct, but ...            01/01/70 00:00      
                        A C compiler can map the hardware quite well            01/01/70 00:00      
                           compiler vendors are looking at the new processors            01/01/70 00:00      
                              I once mentioned that ...            01/01/70 00:00      
                           It's not what I'd choose, but it is a matter of perefernce            01/01/70 00:00      
                              As flash gets bigger, the code steps do too.            01/01/70 00:00      
                              Still not needed for other architectures            01/01/70 00:00      
                                 We will have to agree to disagree ... I guess            01/01/70 00:00      
                                    Which single-clocker is cheaper than an ARM?            01/01/70 00:00      
                                       RE: Which single-clocker is cheaper than an ARM?            01/01/70 00:00      
                                       differs considerably from the classic microcontroller?            01/01/70 00:00      
                                       Horses for courses            01/01/70 00:00      
                                          Always start each project by scanning the market            01/01/70 00:00      
                                             On that we can agree            01/01/70 00:00      
                                          Maybe, but what are they comparing?            01/01/70 00:00      
                                             Did you actually look?            01/01/70 00:00      
                                                Yes, I did.            01/01/70 00:00      
                                       it's a tradeoff            01/01/70 00:00      
                                          Is it 2006 already?            01/01/70 00:00      
                                             Really?            01/01/70 00:00      
                                                that's outright silly            01/01/70 00:00      
                                                   Maybe ... which is why it is not yet the case            01/01/70 00:00      
                                                      the eyes of the beholder            01/01/70 00:00      
                                                         Look at it from another viewpoint for a moment            01/01/70 00:00      
                                          RE: I'm not the one to ask about IC prices            01/01/70 00:00      
                                             doesn't mean I'm totally in the dark            01/01/70 00:00      
                                                Richard Erlacher has left the planet            01/01/70 00:00      
                                                   Maybe Andy's the one who's lost            01/01/70 00:00      
                                                      I cannot believe you even looked at ARM            01/01/70 00:00      
                                                         It's all relative            01/01/70 00:00      
                                                            Price doesn't directly follow processor size            01/01/70 00:00      
                                                            What about performance?            01/01/70 00:00      
                                                         Be specific please.            01/01/70 00:00      
                                                            You can use your own supplier            01/01/70 00:00      
                                                               Your test simulates as 41.04us            01/01/70 00:00      
                                                                  RE: ARM compiles do not like byte-addressing            01/01/70 00:00      
                                                                     A typo on my part            01/01/70 00:00      
                                                                        Case of full unroll            01/01/70 00:00      
                                                                           ... and what does THAT ARM MCU cost?            01/01/70 00:00      
                                                                              WHO CARES            01/01/70 00:00      
                                                                                 Absolutely true!            01/01/70 00:00      
                                                                              $5 or lower            01/01/70 00:00      
                                                                                 My Simulation times were wrong.            01/01/70 00:00      
                                                                                    67% of your loop was your loop            01/01/70 00:00      
                                                                                    re-written the loop in C            01/01/70 00:00      
                                                                                       Try without loop counter            01/01/70 00:00      
                                                                                          You're right!            01/01/70 00:00      
                                                                                             Similar trick with ARM7 would require 66.67MHz            01/01/70 00:00      
                                                                                             60ns with no store instruction.            01/01/70 00:00      
                                                                                                25% speedup            01/01/70 00:00      
                                                                                                   Actually, I found the for loop faster.            01/01/70 00:00      
                                                                                                      Compiler setting?            01/01/70 00:00      
                                                                                                         I made NO optimisation            01/01/70 00:00      
                                                                                                            Avoid variable aliasing if you like high optimization levels            01/01/70 00:00      
                                                                                                               The RealView compiler is very competent            01/01/70 00:00      
                                                                                                                  Yes, caching            01/01/70 00:00      
                                                                                                                  Yes, caching            01/01/70 00:00      
                                                                                                It's much easier with the 8-bit single-clocker            01/01/70 00:00      

Back to Subject List