Click here to Skip to main content
15,904,156 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: There are many gotos, but these ones are mine Pin
Amarnath S11-May-24 17:02
professionalAmarnath S11-May-24 17:02 
GeneralRe: There are many gotos, but these ones are mine Pin
trønderen11-May-24 17:40
trønderen11-May-24 17:40 
GeneralRe: There are many gotos, but these ones are mine Pin
honey the codewitch11-May-24 18:01
mvahoney the codewitch11-May-24 18:01 
GeneralRe: There are many gotos, but these ones are mine Pin
trønderen12-May-24 8:15
trønderen12-May-24 8:15 
GeneralRe: There are many gotos, but these ones are mine Pin
honey the codewitch12-May-24 8:28
mvahoney the codewitch12-May-24 8:28 
GeneralRe: There are many gotos, but these ones are mine Pin
honey the codewitch12-May-24 13:56
mvahoney the codewitch12-May-24 13:56 
GeneralRe: There are many gotos, but these ones are mine Pin
den2k8812-May-24 23:08
professionalden2k8812-May-24 23:08 
GeneralRe: There are many gotos, but these ones are mine Pin
trønderen13-May-24 0:17
trønderen13-May-24 0:17 
Table driven implementations usually reduces the control code to typically a couple hundred bytes (or even less), at the expense of data space for the table.

By using data elements no larger than required in the transition table entries, each entry can be kept to a very moderate size.

One possible issue is the number of states and events. It takes some experience to control both, to keep the table size (#states * #events) under control. A common trick is to introduce 'state variables'.
Some times you can use 2+ small tables rather than a huge one, e.g. if you implement a communication protocol: One table for the connect phase, one for the data transfer phase.

Many transition tables are rather sparse anyway, but a lot of methods for space efficient storage of sparse matrices are basic data structure knowledge. E.g. non-empty entries may be factored out to a packed, linear array, and the large table contains indexes to this array. Often, several transitions are identical (typically in one state, for different events, or for one event in several different states) - then a linear table need to hold only a single copy.

Certainly, really old embedded processors (such as 8051) had very little data space; expanding code space was far easier (e.g. through banking hardware). While we would usually call the transition table 'data', it is 100% read-only, and may very well be burnt in ROM (ok, call it 'flash' nowadays) together with the driver code.

If you consider CLR for an embedded CPU (don't try that on an 8051!), then you definitely can fit a packed transition table. My guess is that the total code+data size would be significantly smaller than an equivalent implementation with switch cases and/or if/else-sequences. And faster, even if a packed table will lead to a couple more indirections.

I will maintain that table driven state machines can be a very good solution for embedded processors.

Religious freedom is the freedom to say that two plus two make five.

GeneralRe: There are many gotos, but these ones are mine Pin
giulicard13-May-24 6:59
giulicard13-May-24 6:59 
GeneralRe: There are many gotos, but these ones are mine Pin
honey the codewitch13-May-24 9:21
mvahoney the codewitch13-May-24 9:21 
GeneralRe: There are many gotos, but these ones are mine Pin
giulicard13-May-24 10:03
giulicard13-May-24 10:03 
GeneralRe: There are many gotos, but these ones are mine Pin
honey the codewitch13-May-24 10:04
mvahoney the codewitch13-May-24 10:04 
GeneralRe: There are many gotos, but these ones are mine Pin
giulicard13-May-24 10:07
giulicard13-May-24 10:07 
GeneralRe: There are many gotos, but these ones are mine Pin
trønderen14-May-24 5:10
trønderen14-May-24 5:10 
GeneralRe: There are many gotos, but these ones are mine Pin
honey the codewitch14-May-24 6:21
mvahoney the codewitch14-May-24 6:21 
GeneralRe: There are many gotos, but these ones are mine Pin
trønderen14-May-24 13:12
trønderen14-May-24 13:12 
GeneralRe: There are many gotos, but these ones are mine Pin
honey the codewitch14-May-24 13:14
mvahoney the codewitch14-May-24 13:14 
GeneralRe: There are many gotos, but these ones are mine Pin
trønderen14-May-24 14:12
trønderen14-May-24 14:12 
GeneralRe: There are many gotos, but these ones are mine Pin
honey the codewitch14-May-24 14:13
mvahoney the codewitch14-May-24 14:13 
GeneralRe: There are many gotos, but these ones are mine Pin
trønderen14-May-24 14:25
trønderen14-May-24 14:25 
GeneralRe: There are many gotos, but these ones are mine Pin
honey the codewitch14-May-24 14:31
mvahoney the codewitch14-May-24 14:31 
GeneralRe: There are many gotos, but these ones are mine Pin
trønderen14-May-24 15:02
trønderen14-May-24 15:02 
GeneralRe: There are many gotos, but these ones are mine Pin
honey the codewitch14-May-24 15:03
mvahoney the codewitch14-May-24 15:03 
GeneralRe: There are many gotos, but these ones are mine Pin
trønderen14-May-24 17:41
trønderen14-May-24 17:41 
GeneralRe: There are many gotos, but these ones are mine Pin
honey the codewitch14-May-24 18:06
mvahoney the codewitch14-May-24 18:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.