Re: 8051 and a C switch statement



Martin Griffith <mart_in_medina@xxxxxxxx> writes:

Got a 4k8 serial biphase signal being decoded by a at85c52 with an
external non retrig monostable (hc221), and I'm running out of time
occasionally waiting for the generic 2*8 LCD to clear it's busy flag.
The LCD is fed with the info from the incoming biphase

To reduce the "reaction time" I could use a long switch statement on
the signal's clock interrupt bitcount from the sync word, 80 per
frame, do just a little bit each interrupt.

The real question is

" how big can I make the switch statement?"
Whats the limit?
I'm using the rasionance C compiler.

I don't fully comprehend what you are trying to do :)

However, a decent compiler will turn a long switch statement into a
jump table equivalent - but you will want to look at the generated
assembler output to be sure it is doing this.

I don't think there is a limit to length in the C language - certainly
not one that matters on a 8052. Of course a defective compiler could
impose it's own limit.

'scuse typos, a bottle of wine was preferable to staring at my
lamentable code


--

John Devereux
.



Relevant Pages

  • 8051 and a C switch statement
    ... occasionally waiting for the generic 2*8 LCD to clear it's busy flag. ... To reduce the "reaction time" I could use a long switch statement on ... the signal's clock interrupt bitcount from the sync word, ...
    (comp.arch.embedded)
  • Re: 8051 and a C switch statement
    ... occasionally waiting for the generic 2*8 LCD to clear it's busy flag. ... To reduce the "reaction time" I could use a long switch statement on ... do just a little bit each interrupt. ... depending on your compiler. ...
    (comp.arch.embedded)
  • Re: 8051 and a C switch statement
    ... occasionally waiting for the generic 2*8 LCD to clear it's busy flag. ... To reduce the "reaction time" I could use a long switch statement on ... do just a little bit each interrupt. ... depending on your compiler. ...
    (comp.arch.embedded)
  • Re: hi i am a girl who were trying a bit on C can someone help?
    ... You may want to take a look at the compiler warnings that get issued. ... your code, with those tabs set at ... >empty, empty); ... You may want to convert the if/else ladder into a switch statement. ...
    (comp.lang.c)
  • Re: Handling 5000 different functionalities - Optimised way in C
    ... the jump table that's typically used to implement a switch statement. ... Perhaps that's not technically a jump table, but AFAIK it's the closest thing* one can implement in C, therefore the name is descriptive enough. ... I agree that the compiler _could_ generate something faster, by jumping to code inside the same function instead of calling another function, but that shouldn't be a noticeable difference. ... that assumes the table is sorted, which may not always be true, my first attempt was obviously wrong and I decided getting the point across was more important than figuring out how to code a binary search on a non-power-of-two-sized array, and a binary search may have a larger I-cache footprint, bomb the branch predictor, and/or confuse the data prefetcher.) ...
    (comp.lang.c)