Re: 8051 and a C switch statement



robertwessel2@xxxxxxxxx wrote:

The C standard (C89/90) requires that the implementation support at
least 257 labels in a switch statement. This is unlikely to be an
issue for an 8052.

To at least some extent it is. A jump table on an 8052 can only comfortably host about 120 entries, because of the limited reach of the indirect jmp and the length of the jmp instruction it leads to.

So a switch with more than those 120 entries will have to be slower than others.
.



Relevant Pages

  • Re: switch() Statement Question
    ... other things) at least "1023 case labels for a switch statement ... Let's suppose a cross-compiler for an embedded system ... can support only half a dozen 'case' labels. ... to break if you decide to move your "portable, strictly conforming" ...
    (comp.lang.c)
  • Re: switch without breaks
    ... Why, though, are subsequent cases not evaluated? ... case labels are just that -- labels b) the numbers for the cases have to be compile time constants. ... a switch statement with breaks ...
    (comp.lang.c)
  • Re: Output of the following code
    ... compound statement that forms the body of a switch statement. ... is merely a goto in disguise. ... This is why case labels are labels, ... Reading email is like searching for food in the garbage, ...
    (comp.lang.c)
  • Re: switch() Statement Question
    ... //Note the fallthrough to the INIT case. ... The body of a switch statement is just a block, ... the case and default labels are just labels in that block. ... we don't ask "When does control reach the `)' of a `for'?" ...
    (comp.lang.c)
  • Re: switch() Statement Question
    ... //Note the fallthrough to the INIT case. ... The body of a switch statement is just a block, ... the case and default labels are just labels in that block. ... before a block's first statement is not mandatory. ...
    (comp.lang.c)