ArticleslgStudy

engineering

Control table

Control table is a engineering topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Control table rather than just read about it. In short: A control table is a table used to direct the control flow of a computer program. Software that uses a control table is said to be table-driven.

Control table — main illustration
Control table — illustration

Key takeaways

  • Control table belongs to engineering; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Control table to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Control table from memory before moving on to harder problems.

Reference excerpt

A control table is a table used to direct the control flow of a computer program. Software that uses a control table is said to be table-driven. A control table encodes both the parameters to a conditional expression and a function reference. An interpreter processes a table by evaluating the conditional expression for input data and invoking the selected function. Using a control table can reduce the need for repetitive code that implements the same logic. In general, the mapping of input parameters can be via any data structure. A common data structure is the lookup, which provides relatively high performance but at a relatively high memory footprint. An associative array can minimize memory use at the cost of more lookup time. How the associated behavior is referenced varies. Some languages provide a direct function reference (i.e. pointer) that can be used to invoke a function directly, but some languages do not. Some languages provide for jumping to a location (i.e.label). As a fallback, any language allows for mapping input to an index that can then be used to branch to a particular part of the code. A control table is often used as part of a higher-level algorithm. It can control the main loop of an event-driven program. A relatively advanced use is instructions for a virtual machine – similar to bytecode but usually with operations implied by the table structure itself instead of encoded in the table data.

Data structure A table can be structured in a variety of ways. It may have one or multiple dimensions and be of fixed or variable length. The structure of the table may be similar to a multimap associative array, where a data value (or combination of data values) may be mapped to one or more functions to be performed. Often, the structure allows tabular data is portable between computer platforms as long as a compatible interpreter exists on each platform.

Trivial hash function A relatively simple implementation consists of a sparse, one-dimensional array of values. The index space is fully covered by the array such that lookup involves indexing into the array by the input value, and a value is found even for an index that is not intended to be used; this prevents an error that might otherwise occur for an unused index value. The lookup is achieved in constant time, without searching. In most architectures, this can be accomplished in two or three machine instructions. The technique is known as a "trivial hash function" or, when used specifically for branch tables, "double dispatch". To be feasible, the range of index values should be relatively small. In the example below, the control table is indexed by ASCII value so it has 256 entries (an entry for each ASCII value); omitted entries are shown as '...'. Only the values for the letter A, D, M, and S are important. All other values are uninteresting and set to 0. A two-byte index would require a minimum of 65,536 entries to handle all input possibilities – which might consume more memory than is considered worth the value it provides.

In automata-based programming and pseudoconversational transaction processing, if the number of distinct program states is small, a "dense sequence" control variable can be used to efficiently dictate the entire flow of the main program loop.

Branch table A branch table is a one-dimensional array of machine code branch/jump instructions to effect a multiway branch to a program label when branched into by an immediately preceding, and indexed branch. It is sometimes generated by an optimizing compiler to execute a switch statement – provided that the input range is small and dense, with few gaps. (as created by the previous array example) Although quite compact – compared to the multiple equivalent If statements – the branch instructions still carry some redundancy, since the branch opcode and condition code mask are repeated alongside the branch offsets. Control tables containing only the offsets to the program labels can be constructed to overcome this redundancy (at least in assembly languages) and yet requiring only minor execution time overhead compared to a conventional branch table.

Decision table Often, a control table implements a decision table, which like a control table contains (often implied) propositions, and one or more associated actions. A control table can act like a switch statement or more generally as a nested if-then-else construct that includes logical predicates (using boolean style AND/OR conditions) for each case. Such a control table provides for a language-independent implementation of what otherwise is a language-dependent construct. The table embodies the essence of a program, stripped of programming language syntax and platform dependent aspects, and condensed to data and implied logic. The meaning of the table includes implied operations instead of being explicit as in a more typical programming paradigm. Typically, a two-dimensional control table contains value/action pairs and may additionally contain operators and type information such as the location, size and format of input or output data, whether data conversion is required. The table may contain indexes or relative or absolute pointers to generic or customized primitives or functions to be executed depending upon other values in the row. The type of values used in a control table depends on the computer language used for the interpreter. Assembly language provides the widest scope for data types including machine code for lookup values. Typically, a control table contains values for each possible matching class of input together with a corresponding pointer to an action function. For a language without pointer support, the table can encode an index which can imply an offset value that can be used to accomplish the same as a pointer.

Storage A control table can be stored in a variety of ways. It can be stored as part of a program, for example as a static variable. It can be stored in the file system, for example as a flat file or in a database. It can be built dynamically by the program. For efficiency, the table should be resident in program memory when the interpreter uses it.

… excerpt ends here. Continue reading the full article.

Illustrations

Control table: Control table that directs program flow according to the value of a single input value. Each entry holds a possible input value and a reference to an associated function.
Control table that directs program flow according to the value of a single input value. Each entry holds a possible input value and a reference to an associated function.

Worked examples

Example 1 — a first encounter with Control table

Start with the simplest possible case. Write down what Control table claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In engineering, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Control table before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Control table ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Control table

In research
Control table appears in engineering research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Control table in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Control table is common in secondary-school and first-year university syllabi. It links to neighbouring topics Compiler construction, Compiler structures, Control flow, so understanding it makes those chapters shorter.
In everyday life
Look for Control table outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Control table” →

How to study Control table in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Control table means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Control table out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Control table in simple terms?

A control table is a table used to direct the control flow of a computer program. Software that uses a control table is said to be table-driven.

Why does Control table matter?

Because it connects several engineering ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Control table?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Control table.

Tags

  • Compiler construction
  • Compiler structures
  • Control flow

Keep exploring