
<opts>
<isrc>keybd</isrc>
<iname>INPUT</iname>
<iecho>yes</iecho>
<odest>screen</odest>
<oname>OUTPUT</oname>
<onewl>lf</onewl>
<cfmt>~\n</cfmt>
<citer>1</citer>
<cdisp>nolist</cdisp>
<rtype>fmt</rtype>
<rfmt>\n\N</rfmt>
<rall>yes</rall>
<starg>junk</starg>
<srpl></srpl>
<scount>1</scount>
<sout>yes</sout>
<nfmt>general</nfmt>
<ndec>2</ndec>
<nang>degrees</nang></opts>
<cell>
<cname>accum</cname>
<text>Value in accumulator at entry to loop</text>
<val>200</val></cell>
<cell>
<cname>cycle</cname>
<text>This contains the bus cycle time in seconds</text>
<val>5E-07</val></cell>
<cell>
<cname>home</cname>
<text>This web computes the time required to execute a Motorola 68HC705J1a wait loop, given the value in the accumulator on entry.  The system clock is assumed to be 4.0MHz, resulting in a 500 nanosecond cycle time.

The timing loop, with cycles per instruction is:

Await  TAX                   ;   2
Olp        TXA                  ;    2
               TSTA               ;   3
                BNE  Ilp          ;   3
                RTS                 ;   6
Ilp          SUB   #1         ;   2
               NOP                  ;  2
               NOP                  ;  2
               NOP                  ;  2
               NOP                  ;  2
               BNE  Ilp           ;  3
               DECX                ;  3
               BRA  Olp          ;  3

Time per execution of the outer loop is:  2+3+3+3+3=14
Time per execution of the inner loop is:  2+2+2+2+2+3=13

INSTRUCTIONS:
1) Place the initial accumulator value into the value field of cell accum.
2) Select Execute from the Special menu.
3) Read the answer in seconds in the value field of the home cell.
</text>
<val>0.132061</val>
<script>set totalCycles to 0
for(indx=accum to 0 step -1) {
    set totalCycles  to
          totalCycles+outerCycles+indx*innerCycles
} #endfor
set totalCycles to totalCycles+8
totalCycles*cycle</script></cell>
<cell>
<cname>indx</cname>
<text>Index of for loop for computing total bus cycles</text>
<val>0</val></cell>
<cell>
<cname>innerCycles</cname>
<text>Number of bus cycles in one repetition of the inner loop</text>
<val>13</val></cell>
<cell>
<cname>outerCycles</cname>
<text>Number of bus cycles attributable to outer loop code in one repetition of the outer loop </text>
<val>14</val></cell>
<cell>
<cname>totalCycles</cname>
<text>This variable accumulates bus cycles during computation</text>
<val>264122</val></cell></eof>