⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chapter 10 functions -- valvano.htm

📁 介绍了在嵌入式系统中如何用c来设计嵌入式软件
💻 HTM
📖 第 1 页 / 共 4 页
字号:
y<BR>&nbsp;&nbsp;&nbsp;&nbsp;pulx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;deallocate 
z1<BR>&nbsp;&nbsp;&nbsp;&nbsp;rts<BR>&nbsp;&nbsp;&nbsp;&nbsp;.globl 
_main<BR>;&nbsp;&nbsp;&nbsp;y -&gt; 
4,x<BR>_main:<BR>&nbsp;&nbsp;&nbsp;&nbsp;pshx&nbsp;&nbsp;&nbsp;;allocate 
y<BR>&nbsp;&nbsp;&nbsp;&nbsp;pshx&nbsp;&nbsp;&nbsp;;allocate temporary 
(z3)<BR>&nbsp;&nbsp;&nbsp;&nbsp;pshx&nbsp;&nbsp;&nbsp;;allocate temporary 
(z2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;tsx<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd&nbsp;&nbsp;#1000<BR>&nbsp;&nbsp;&nbsp;&nbsp;std&nbsp;&nbsp;_x1&nbsp;&nbsp;&nbsp;;x1=1000<BR>&nbsp;&nbsp;&nbsp;&nbsp;std&nbsp;&nbsp;_x2&nbsp;&nbsp;&nbsp;;x2=1000<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd&nbsp;&nbsp;_x3<BR>&nbsp;&nbsp;&nbsp;&nbsp;std&nbsp;&nbsp;2,x&nbsp;&nbsp;&nbsp;;z3=x3<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd&nbsp;&nbsp;_x2<BR>&nbsp;&nbsp;&nbsp;&nbsp;std&nbsp;&nbsp;0,x&nbsp;&nbsp;&nbsp;;z2=x2<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd&nbsp;&nbsp;_x1&nbsp;&nbsp;&nbsp;;RegD=x1<BR>&nbsp;&nbsp;&nbsp;&nbsp;jsr&nbsp;&nbsp;_add3<BR>&nbsp;&nbsp;&nbsp;&nbsp;tsx<BR>&nbsp;&nbsp;&nbsp;&nbsp;std&nbsp;&nbsp;4,x&nbsp;&nbsp;&nbsp;;y=x1+x2+x3<BR>&nbsp;&nbsp;&nbsp;&nbsp;pulx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;deallocate 
temporary 
(z2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;pulx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;deallocate 
temporary 
(z3)<BR>&nbsp;&nbsp;&nbsp;&nbsp;pulx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;deallocate 
y<BR>&nbsp;&nbsp;&nbsp;&nbsp;rts<BR>&nbsp;&nbsp;&nbsp;&nbsp;.area 
bss&nbsp;&nbsp;&nbsp;;RAM<BR>_x2: .blkb 2<BR>&nbsp;&nbsp;&nbsp;&nbsp;.globl 
_x1<BR>_x1: .blkb 2</CODE></P></DIR>
<ADDRESS>Listing 10-10: ICC11 assembly of function call with local 
variables</ADDRESS>
<P><FONT face="Times New Roman,Times">The stack frame at the time of the 
</FONT><B><FONT face=Courier>addd</FONT></B><FONT face="Times New Roman,Times"> 
instructions is shown in Figure 10-3. Within the subroutine the local variables 
of main are not accessible.</FONT></P>
<P><IMG height=218 src="Chapter 10 Functions -- Valvano.files/Image39.gif" 
width=330></P>
<ADDRESS>Figure 10-3: ICC11 stack within the add3 function</ADDRESS>
<P>&nbsp;</P>
<P><FONT face="Times New Roman,Times">The second compiler we will study is the 
ImageCraft ICC12 version 5.1 for the Motorola 6812. This disassembled output 
also has been edited to clarify its operation. The linker/loader allocates 3 
segmented memory areas: code pointed to by the PC; global accessed with absolute 
addressing; and locals pointed to by the stack pointer SP. The global symbols, 
<B>_x1 _x2_x3</B>, will be assigned or bound by the linker/loader. The three 
instructions <B>pshx tfr s,x </B>and<B> leas -8,sp</B> allocates the local 
variable, and establishes a stack frame pointer, X. This compiler passes the 
first input parameter (<B>z1</B>) into the subroutine by placing it in register 
D. The remaining parameters (<B>z2</B>, <B>z3</B> in this example) are pushed on 
the stack by the main program before the subroutine is called. The first 
operation the subroutine performs is to push the remaining parameter on the 
stack (<B>pshd</B>) so that all three parameters,<B> z1 z2 z3</B>, are on the 
stack. Also notice that the <B>main</B> program allocates space for the 
parameters it needs to push when it calls <B>add3</B> at the beginning of 
<B>main</B>.</FONT></P>
<P>&nbsp;</P>
<ADDRESS><IMG height=224 src="Chapter 10 Functions -- Valvano.files/Image40.gif" 
width=333></ADDRESS>
<ADDRESS>Figure 10-4: ICC12 stack within the add3 function</ADDRESS>
<DIR>
<P><CODE>&nbsp;&nbsp;&nbsp;&nbsp;.area text<BR>_x3:: .word 
1000<BR>&nbsp;&nbsp;&nbsp;&nbsp;.area text<BR>; y -&gt; -2,x<BR>; z3 -&gt; 
8,x<BR>; z2 -&gt; 6,x<BR>; z1 -&gt; 2,x<BR>_add3:: 
pshd<BR>&nbsp;&nbsp;&nbsp;&nbsp;pshx<BR>&nbsp;&nbsp;&nbsp;&nbsp;tfr 
s,x<BR>&nbsp;&nbsp;&nbsp;&nbsp;leas -2,sp<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd 
2,x<BR>&nbsp;&nbsp;&nbsp;&nbsp;addd 6,x<BR>&nbsp;&nbsp;&nbsp;&nbsp;addd 
8,x<BR>&nbsp;&nbsp;&nbsp;&nbsp;std -2,x<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd 
-2,x<BR>&nbsp;&nbsp;&nbsp;&nbsp;tfr 
x,s<BR>&nbsp;&nbsp;&nbsp;&nbsp;pulx<BR>&nbsp;&nbsp;&nbsp;&nbsp;leas 
2,sp<BR>&nbsp;&nbsp;&nbsp;&nbsp;rts<BR>; y -&gt; -2,x<BR>_main:: 
pshx<BR>&nbsp;&nbsp;&nbsp;&nbsp;tfr s,x<BR>&nbsp;&nbsp;&nbsp;&nbsp;leas 
-8,sp<BR>&nbsp;&nbsp;&nbsp;&nbsp;movw #1000,_x1<BR>&nbsp;&nbsp;&nbsp;&nbsp;movw 
#1000,_x2<BR>&nbsp;&nbsp;&nbsp;&nbsp;movw 
_x3,2,sp<BR>&nbsp;&nbsp;&nbsp;&nbsp;movw _x2,0,sp<BR>&nbsp;&nbsp;&nbsp;&nbsp;ldd 
_x1<BR>&nbsp;&nbsp;&nbsp;&nbsp;jsr _add3<BR>&nbsp;&nbsp;&nbsp;&nbsp;std 
-4,x<BR>&nbsp;&nbsp;&nbsp;&nbsp;tfr d,y<BR>&nbsp;&nbsp;&nbsp;&nbsp;sty 
-2,x<BR>&nbsp;&nbsp;&nbsp;&nbsp;tfr 
x,s<BR>&nbsp;&nbsp;&nbsp;&nbsp;pulx<BR>&nbsp;&nbsp;&nbsp;&nbsp;rts<BR>.area 
bss<BR>_x2:&nbsp;&nbsp;&nbsp;.blkb 2<BR>_x1::&nbsp;&nbsp;.blkb 
2</CODE></P></DIR>
<ADDRESS>Listing 10-11: ICC12 assembly of function call with local 
variables</ADDRESS>
<P><A name=ANIMATION></A><IMG height=395 
src="Chapter 10 Functions -- Valvano.files/stck.gif" width=393></P>
<ADDRESS>Figure 10-5: ICC12 animation of the add3 function</ADDRESS>
<P><B><I><FONT face=Helvetica,Arial><A name=FSM></A>Finite State Machine using 
Function Pointers</FONT></I></B></P>
<P><FONT face="Times New Roman,Times">Now that we have learned how to declare, 
initialize and access function pointers, we can create very flexible finite 
state machines. In the finite state machine presented in <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap9/chap9.htm#FSMDEFINITION">Listing 
9-2</A> and <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap9/chap9.htm#FSMPROGRAM">Listing 
9-4</A>, the output was a simple number that is written to the output port. In 
this next example, we will actually implement the exact same machine, but in a 
way that supports much more flexibility in the operations that each state 
performs. In fact we will define a general C function to be executed at each 
state. In this implementation the functions perform the same output as the 
previous machine.</FONT></P>
<P><IMG height=205 src="Chapter 10 Functions -- Valvano.files/fsm.GIF" 
width=387></P>
<ADDRESS>Figure 10-6: Finite State Machine (same as Figure 9-1)</ADDRESS>
<P><FONT face="Times New Roman,Times">Compare the following implementation to <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap9/chap9.htm#FSMDEFINITION">Listing 
9-2</A>, and see that the <B>unsigned char Out;</B> constant is replaced with a 
<B>void (*CmdPt)(void);</B> function pointer. The three general function 
<B>DoStop() DoTurn()</B> and <B>DoBend()</B> are also added.</FONT></P>
<DIR>
<P><CODE>const&nbsp;struct&nbsp;State{<BR>&nbsp;&nbsp;&nbsp;&nbsp;</CODE><FONT 
face=Courier size=2>void</FONT><CODE>&nbsp;</CODE><FONT face=Courier 
size=2>(*CmdPt)(void);</FONT><CODE>&nbsp;&nbsp;&nbsp;</CODE><FONT face=Courier 
size=2>/* function to execute 
*/</FONT><CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;int&nbsp;Wait;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Time&nbsp;(E&nbsp;cycles)&nbsp;to&nbsp;wait&nbsp;*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;char&nbsp;AndMask[4];<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;char&nbsp;EquMask[4];<BR>&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;struct&nbsp;State&nbsp;*Next[4];};&nbsp;&nbsp;/*&nbsp;Next&nbsp;states&nbsp;*/<BR>typedef&nbsp;const&nbsp;struct&nbsp;State&nbsp;StateType;<BR>typedef&nbsp;StateType&nbsp;*&nbsp;StatePtr;<BR>#define&nbsp;stop&nbsp;&amp;fsm[0]<BR>#define&nbsp;turn&nbsp;&amp;fsm[1]<BR>#define&nbsp;bend&nbsp;&amp;fsm[2]<BR></CODE><FONT 
face=Courier size=2>void DoStop(void){</FONT><CODE>&nbsp;&nbsp;</CODE><FONT 
face=Courier size=2>PORTH=0x34;}</FONT><CODE><BR></CODE><FONT face=Courier 
size=2>void DoTurn(void){</FONT><CODE>&nbsp;&nbsp;</CODE><FONT face=Courier 
size=2>PORTH=0xB3;}</FONT><CODE><BR></CODE><FONT face=Courier size=2>void 
DoBend(void){</FONT><CODE>&nbsp;&nbsp;</CODE><FONT face=Courier 
size=2>PORTH=0x75;}</FONT><CODE><BR>StateType&nbsp;fsm[3]={<BR>{</CODE><FONT 
face=Courier 
size=2>&amp;DoStop</FONT><CODE>,&nbsp;2000,&nbsp;&nbsp;&nbsp;//&nbsp;stop&nbsp;1&nbsp;ms<BR>&nbsp;&nbsp;&nbsp;{0xFF,&nbsp;&nbsp;&nbsp;0xF0,&nbsp;&nbsp;&nbsp;0x27,&nbsp;&nbsp;&nbsp;0x00},<BR>&nbsp;&nbsp;&nbsp;{0x51,&nbsp;&nbsp;&nbsp;0xA0,&nbsp;&nbsp;&nbsp;0x07,&nbsp;&nbsp;&nbsp;0x00},<BR>&nbsp;&nbsp;&nbsp;{turn,&nbsp;&nbsp;&nbsp;stop,&nbsp;&nbsp;&nbsp;turn,&nbsp;&nbsp;&nbsp;bend}},<BR>{</CODE><FONT 
face=Courier 
size=2>&amp;DoTurn</FONT><CODE>,5000,&nbsp;&nbsp;&nbsp;//&nbsp;turn&nbsp;2.5&nbsp;ms<BR>&nbsp;&nbsp;&nbsp;{0x80,&nbsp;&nbsp;&nbsp;0xF0,&nbsp;&nbsp;&nbsp;0x00,&nbsp;&nbsp;&nbsp;0x00},<BR>&nbsp;&nbsp;&nbsp;{0x00,&nbsp;&nbsp;&nbsp;0x90,&nbsp;&nbsp;&nbsp;0x00,&nbsp;&nbsp;&nbsp;0x00},<BR>&nbsp;&nbsp;&nbsp;{bend,&nbsp;&nbsp;&nbsp;stop,&nbsp;&nbsp;&nbsp;turn,&nbsp;&nbsp;&nbsp;turn}},<BR>{</CODE><FONT 
face=Courier 
size=2>&amp;DoBend</FONT><CODE>,4000,&nbsp;&nbsp;&nbsp;//&nbsp;bend&nbsp;2&nbsp;ms<BR>&nbsp;&nbsp;&nbsp;{0xFF,&nbsp;&nbsp;&nbsp;0x0F,&nbsp;&nbsp;&nbsp;0x01,&nbsp;&nbsp;&nbsp;0x00},<BR>&nbsp;&nbsp;&nbsp;{0x12,&nbsp;&nbsp;&nbsp;0x05,&nbsp;&nbsp;&nbsp;0x00,&nbsp;&nbsp;&nbsp;0x00},<BR>&nbsp;&nbsp;&nbsp;{stop,&nbsp;&nbsp;&nbsp;stop,&nbsp;&nbsp;&nbsp;turn,&nbsp;&nbsp;&nbsp;stop}}};</CODE></P></DIR>
<ADDRESS>Listing 10-12: Linked finite state machine structure stored in 
ROM</ADDRESS>
<P>&nbsp;</P>
<P><FONT face="Times New Roman,Times"><A name=CONTROL></A>Compare the following 
implementation to <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap9/chap9.htm#FSMPROGRAM">Listing 
9-4</A>, and see that the <B>PORTH=pt-Out;</B> assignment is replaced with a 
<B>(*Pt-&gt;CmdPt)();</B> function call. In this way, the appropriate function 
<B>DoStop() DoTurn()</B> or <B>DoBend()</B> will be called.</FONT></P>
<DIR>
<P><CODE>void&nbsp;control(void){&nbsp;StatePtr&nbsp;Pt;<BR>&nbsp;unsigned&nbsp;char&nbsp;Input;&nbsp;int&nbsp;Endt;&nbsp;unsigned&nbsp;int&nbsp;i;<BR>&nbsp;&nbsp;</CODE><FONT 
face=Courier size=2>TSCR |=0x80;</FONT><CODE>&nbsp;&nbsp;&nbsp;</CODE><FONT 
face=Courier size=2>// TEN(enable)</FONT><CODE><BR>&nbsp;&nbsp;</CODE><FONT 
face=Courier size=2>TMSK2=0xA2;</FONT><CODE>&nbsp;&nbsp;&nbsp;&nbsp;</CODE><FONT 
face=Courier size=2>// TOI arm, TPU(pullup) timer/4 
(500ns)</FONT><CODE><BR>&nbsp;&nbsp;DDRH=0xFF;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;PortH&nbsp;bits&nbsp;7-0&nbsp;are&nbsp;outputs<BR>&nbsp;&nbsp;DDRJ=0x00;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;PortJ&nbsp;bits&nbsp;7-0&nbsp;are&nbsp;inputs<BR>&nbsp;&nbsp;PUPSJ=0xFF;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Pullups&nbsp;J7-J0<BR>&nbsp;&nbsp;PULEJ=0xFF;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Enable&nbsp;pull&nbsp;up/down&nbsp;PortJ<BR>&nbsp;&nbsp;Pt=stop;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Initial&nbsp;State&nbsp;<BR>&nbsp;&nbsp;while(1){<BR>&nbsp;&nbsp;&nbsp;&nbsp;</CODE><FONT 
face=Courier 
size=2>(*Pt-&gt;CmdPt)();</FONT><CODE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</CODE><FONT 
face=Courier size=2>//</FONT><CODE>&nbsp;</CODE><FONT face=Courier 
size=2>1)</FONT><CODE>&nbsp;</CODE><FONT face=Courier 
size=2>execute</FONT><CODE>&nbsp;</CODE><FONT face=Courier 
size=2>function</FONT><CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;Endt=TCNT+Pt-&gt;Wait;&nbsp;&nbsp;&nbsp;//&nbsp;Time&nbsp;(500 
ns 
each)&nbsp;to&nbsp;wait<BR>&nbsp;&nbsp;&nbsp;&nbsp;while(Endt-TCNT&gt;0);&nbsp;&nbsp;&nbsp;//&nbsp;2)&nbsp;wait&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;Input=PORTJ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;3)&nbsp;input&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;for(i=0;i&lt;4;i++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if((Input&amp;Pt-&gt;AndMask[i])==Pt-&gt;EquMask[i]){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pt=Pt-&gt;Next[i];&nbsp;//&nbsp;4)&nbsp;next&nbsp;depends&nbsp;on&nbsp;input<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i=4;&nbsp;}}};</CODE></P></DIR>
<ADDRESS>Listing 10-13: Finite state machine controller for 
MC68HC812A4</ADDRESS>
<P><B><I><FONT face=Helvetica,Arial><A name=INTERPRETER></A>Linked List 
Interpreter using Function Pointers</FONT></I></B></P>
<P><FONT face="Times New Roman,Times">In the next example, function pointers are 
stored in a listed-list. An interpreter accepts ASCII input from a keyboard and 
scans the list for a match. In this implementation, each node in the linked list 
has a function to be executed when the operator types the corresponding letter. 
The linked list <B>LL</B> has three nodes. Each node has a letter, a function 
and a link to the next node. </FONT></P>
<P><CODE>// Linked List Interpreter<BR>const struct 
Node{<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned char Letter; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;void 
(*fnctPt)(void);<BR>&nbsp;&nbsp;&nbsp;&nbsp;const struct Node *Next;}; 
<BR>typedef const struct Node NodeType;<BR>typedef NodeType * NodePtr;<BR>void 
CommandA(void){<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutString("\nExecuting Command a"); 
<BR>}<BR>void CommandB(void){<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutString("\nExecuting 
Command b"); <BR>}<BR>void 
CommandC(void){<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutString("\nExecuting Command c"); 
<BR>}<BR>NodeType LL[3]={<BR>&nbsp;&nbsp;&nbsp;&nbsp;{ 'a', &amp;CommandA, 
&amp;LL[1]},<BR>&nbsp;&nbsp;&nbsp;&nbsp;{ 'b', &amp;CommandB, 
&amp;LL[2]},<BR>&nbsp;&nbsp;&nbsp;&nbsp;{ 'c', &amp;CommandC, 0 }};<BR>void 
main(void){ NodePtr Pt; char string[40];<BR>&nbsp;&nbsp;&nbsp;&nbsp;InitSCI(); 
// Enable SCI port<BR>&nbsp;&nbsp;&nbsp;&nbsp;TSCR |=0x80;&nbsp;&nbsp;&nbsp;// 
TEN(enable)<BR>&nbsp;&nbsp;&nbsp;&nbsp;TMSK2=0xA2;&nbsp;&nbsp;&nbsp;&nbsp;// TOI 
arm, TPU(pullup) timer/4 (500ns)<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutString("\nEnter a 
single letter command followed by &lt;enter&gt;"); 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;while(1){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OutString("\n&gt;"); 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InString(string,39);&nbsp;// 
first character is 
interpreted<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pt=&amp;LL[0]; // 
first node to 
check<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while(Pt){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(string[0]==Pt-&gt;Letter){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pt-&gt;fnctPt();&nbsp;// 
execute 
function<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// 
leave while 
loop<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pt=Pt-&gt;Next;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(Pt==0) 
OutString(" Error");}}}}<BR></CODE></P>
<ADDRESS>Listing 10-14: Linked list implementation of an interpreter.</ADDRESS>
<P><FONT face="Times New Roman,Times">Compare the syntax of the function call, 
<B>(*Pt-&gt;CmdPt)();</B>, in <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap10/CONTROL">Listing 
10-13</A>, with the syntax in this example, <B>Pt-&gt;fnctPt();</B>. In the 
Imagecraft compilers, these two expressions both generate code that executes the 
function. </FONT></P>
<P><FONT face="Times New Roman,Times">Go to <A 
href="http://www.ece.utexas.edu/~valvano/embed/chap11/chap11.htm">Chapter 11 on 
Preprocessor Directives</A> Return to <A 
href="http://www.ece.utexas.edu/~valvano/embed/toc1.htm">Table of 
Contents</A></FONT></P></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -