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 17:57
Read: times


 
#165300 - I WOULD write thsi in C
Responding to: ???'s previous message
I took a command parser I wrote in Keil C for the 8051 (SiLabs variants) and ported it with few changes to Xilinx MicroBlaze and PPC. In all cases, a serial-port handler accepted incoming characters until an end-of-line termination is found, and passes that buffer to the parser. The parser was identical, except for the specific commands, of course, for each project.

The parser looks for an 'S' or 'G' character (set or get), then a space, then a two-character command. A loop compares the two-character command string and if a match is found then a token is set indicating the command (this falls out of the loop iterator). If we test all commands and we don't find a match, then the parser exits with an "invalid command" indicator.

Once it has a token, it's a simple switch statement based on that token to actually interpret the command. This compiles to a nice jump table, as you'd expect.

-a

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