/* Linked List Interpreter filename Interp11.C Simulator program of a Moore Finite State Machine This example accompanies the book "Embedded Microcomputer Systems: Real Time Interfacing", Brooks-Cole, copyright (c) 2000, Jonathan W. Valvano 7/6/99 Interface between the TExaS simulator running a MC68HC11 EVB with ICC11 freeware compiler TExaS Copyright 1999 by Jonathan W. Valvano for more information about ICC11 see http://www.imagecraft.com You may use this file without restrictions */ #include "HC11.h" #include "SCI11.H" const struct Node{ unsigned char Letter; /* letter you type */ void (*fnctPt)(void); /* function to execute */ const struct Node *Next;}; /* linear linked list */ typedef const struct Node NodeType; typedef NodeType * NodePtr; void CommandA(void){ OutString("\rExecuting Command a"); } void CommandB(void){ OutString("\rExecuting Command b"); } void CommandC(void){ OutString("\rExecuting Command c"); } NodeType LL[3]={ /* linear linked list */ { 'a', &CommandA, &LL[1]}, { 'b', &CommandB, &LL[2]}, { 'c', &CommandC, 0 }}; NodePtr Pt; char string[40]; void main(void){ InitSCI(); OutString("\rInterpreter example 5/1/98 -JWV"); OutString("\rEnter a single letter command followed by "); while(1){ OutString("\r>"); InString(string,39); Pt=&LL[0]; /* first node to check */ while(Pt){ if(string[0]==Pt->Letter){ Pt->fnctPt(); Pt=0;} else{ Pt=Pt->Next; if(Pt==0) OutString(" Error");}}}} #include "SCI11.C" void resetVectors(void){ /* not really a function, but this must be last */ asm(" org $FFFE"); asm(" FDB __start"); asm(" org $FC00"); /* puts rts in a harmless place */ /* string constants also placed here */ /* the value FC00 means you can have up to 1000 characters of strings */ }