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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/13/09 19:50
Read: times


 
#165304 - In this case, speed isn't a big factor.
Responding to: ???'s previous message
Erik Malund said:
Richard Erlacher said:This particular function will go VERY fast in the manner I've cursorily described, use very limited resources, and, I'm quite well persuaded, would be much slower in 'C'
Andy replied :A decent 'C' compiler can make good use of lookup tables as you describe - so it still might not be that bad.

Then again, it might be.


The opinion that assembler is faster than C is often correct.

if you compare C without any concern (e.g. using the 'large' model) to well crafted assembler it is, indeed true. I have, however seen examples of qualified C coders writing assembler with very little understanding of the hardware and ending up with assembler that was worse than their C.

However for a person well versed in both C and assembler, it can be beneficial to write a function or two in asm for reasons of throughput.

Erik



I would certainly agree that in this particular application, where the "commands" are coming from a console of user interface of some sort, driven by a human, it matters little how fast the code is. I stand by my claim, however, that the compiler, no matter whose compiler it is, couldn't and therefore wouldn't produce code that's faster and smaller than the code a reasonably competent ASM programmer with some understanding of the environment he's programming would produce.

Yes, there's many a slip 'twixt cup and lip, and few typical 'C' programmers (the sort that barely pass their 'C' class in college) are even reasonably competent programmers, regardless of the language, yet they all claim to be programmers. Since the compiler produces code with considerable, perhaps not vast amounts, but substantial amounts of overhead, I'd bet the code I write in ASM would be quite a bit shorter and faster than what an all-'C'-code program compiled with your favorite compiler would produce. I wouldn't bet that it would make a lot of difference in this application.

I've been considering using 'C' to produce those occasional non-environment-related routines that occasionally pop up ... you know ... calculating the Julian date once a day ... and other tasks where precise timing or speed isn't a factor. They can sometimes be quite a bit easier to create in 'C'.

Because I like to use table-driven dispatch routines in ASM, for speed and brevity, I'd probably write the MAIN component in ASM, and use compiled modules from the 'C' compiler as macros or subroutines. I'm not sure how easy that would be, however.

RE



List of 29 messages in thread
TopicAuthorDate
Command Processor            01/01/70 00:00      
   More detail required            01/01/70 00:00      
      Command Processor            01/01/70 00:00      
         Standard Async Serial (updated)            01/01/70 00:00      
         What is it that you need?            01/01/70 00:00      
            Command Processor            01/01/70 00:00      
               What compiler?            01/01/70 00:00      
                  Code to Get command            01/01/70 00:00      
                     Buffer overflow...            01/01/70 00:00      
                        Sorry            01/01/70 00:00      
                     did you retype the code?? ....            01/01/70 00:00      
                        This code is translated            01/01/70 00:00      
                           Alternative parsing            01/01/70 00:00      
                              Code to Get command            01/01/70 00:00      
                           wasteful            01/01/70 00:00      
               I would not do this in 'C'            01/01/70 00:00      
                  Thank you            01/01/70 00:00      
                     Assembler floating point?            01/01/70 00:00      
                        I didn't say he shouldn't use 'C' at all ...            01/01/70 00:00      
                  'C' may not be that bad            01/01/70 00:00      
                     Just this particular function would be very fast in ASM            01/01/70 00:00      
                        Maybe; maybe not...            01/01/70 00:00      
                           The opinion that assembler is faster than C            01/01/70 00:00      
                              In this case, speed isn't a big factor.            01/01/70 00:00      
                                 dead easy and it will not work if you do not            01/01/70 00:00      
                                    no (keil?) C will work if the main is in asm            01/01/70 00:00      
                                       What I was considering            01/01/70 00:00      
                  I WOULD write thsi in C            01/01/70 00:00      
                     Thta doesn't surprise me.            01/01/70 00:00      

Back to Subject List