| ??? 11/23/03 20:20 Read: times |
#59268 - RE: Hierarchical menu structure in assembler Responding to: ???'s previous message |
Patrick:
I have designed and built this type of structure many many times. My conclusion as to the best way to do this type of thing on an 8051 where there is a limited stack space is to do it one of two ways. 1) Design it as a state machine wherein there is a global variable (or set of variables) that controls where in the menu structure the current context is located. This solution works very well when the number of menus is reasonably small (say like less than eight). You can use a "call - through" table to preform the current action tranfers from the main loop through to the specific display / key parsing code for each menu. You could reference this code sample for ideas on state machine designs although this example does not have a menu system attached to it ---> State Machine Tutorial. 2) Another way that is a bit more sophisticated but more flexible in that it works good when there are scads of menus is to have a set of function pointers, one for each possible key press. (This scheme also makes it easy to share action subroutines between various menu states). At init time the function pointers are set to the key response routines for the top level menu. Then the keyboard input parser, that is called from the main polling loop, dispatches a call to the function subroutine for for the particular key being pressed by way of the function pointer for that key press. The subroutine that is called may change the display, may change one or more of the function pointers, and may adjust one or more state variables that keep track of something in a menu such as the current value of a parameter that may be adjusted up or down via arrow keys. -------------- There is another much more easy to maintain way to organize menu structures by using a menu table design. The use of such a system is easier to manage in C language and does require more stack space. If you are interested in more information on a table type system I can sent you some C examples from a standalone x86 environment which is certainly portable to the 8051 with the likes of the Keil C compiler. I could also show you some more information about the idea described in #2 above, however that example is in C but could be easily transposed to an assembly language implementation. Michael Karas |
| Topic | Author | Date |
| Hierarchical menu structure in assembler | 01/01/70 00:00 | |
| RE: Hierarchical menu structure in assembler | 01/01/70 00:00 | |
| RE: Hierarchical menu structure in assem | 01/01/70 00:00 | |
| RE: Hierarchical menu structure in assem | 01/01/70 00:00 | |
| RE: Hierarchical menu structure in assem | 01/01/70 00:00 | |
| RE: Hierarchical menu structure in assem | 01/01/70 00:00 | |
| RE: Hierarchical menu structure in assembler | 01/01/70 00:00 | |
RE: thanks for your input | 01/01/70 00:00 |



