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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/01/06 08:53
Read: times


 
#110955 - C gives higher performance!
Responding to: ???'s previous message
M Chitrakar said:
here is the C program of ASM...

No.
The 'C' and ASM code that you show are completely unrelated.

You are comparing apples and oranges - the 'C' and ASM code that you show take two opposite approaches to the problem:

  • The assembler assumes that the UART's transmitter is idle, and puts the character straight into SBUF; it then waits until that character has been completely transmitted - as indicated by TI being set by the hardware.
    Thus your code is effectively "stalled" for the entire duration of the character transmission!

  • The 'C', on the other hand, first waits for the UART's transmitter to become idle - as indicated by TI being set; it then puts the character into SBUF and returns immediately.
    Thus your code is free to get on with other stuff whilst the character is being transmitted; the code will not wait unless the function is called again before the transmission is complete.
    Thus the 'C' version offers potentially higher performance!
    The only proviso is that you need to set TI the very first time to get the very first character started!

  • List of 24 messages in thread
    TopicAuthorDate
    putchar C51 serial communication problem            01/01/70 00:00      
       Keil putchar source            01/01/70 00:00      
       putchar() reworded            01/01/70 00:00      
          TI            01/01/70 00:00      
             thanks and here is my C code of asm...            01/01/70 00:00      
                should be obvious            01/01/70 00:00      
                   To be fair            01/01/70 00:00      
                C gives higher performance!            01/01/70 00:00      
                   Initial conditions            01/01/70 00:00      
                      waiting better than uninten effcy            01/01/70 00:00      
                         Better?            01/01/70 00:00      
                         Math?            01/01/70 00:00      
                         What?????            01/01/70 00:00      
                            no work to do unitl bytes send            01/01/70 00:00      
       OK            01/01/70 00:00      
          or...            01/01/70 00:00      
             That is better            01/01/70 00:00      
                i read about putchar()            01/01/70 00:00      
                   Try \Keil\C51\LIB\getkey.c            01/01/70 00:00      
                   Keil Library Source Files            01/01/70 00:00      
                      ok            01/01/70 00:00      
                         No and Yes            01/01/70 00:00      
                            but what about AT cmd            01/01/70 00:00      
                               No            01/01/70 00:00      

    Back to Subject List