11.07.2015 Views

section 7 - Index of

section 7 - Index of

section 7 - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

START OF LOOP1)SP+ 1 • SP; LA. SSH; LC • SSL; ttxxx. LC2)SP+ 1 • SP; PC. SSH; SR • SSL; Expr-1 • LA3)1. LFEND OF LOOP1)SSL(LF). SR2)SP-1 • SP; SSH • LA; SSL. LC; SP-1 • SP3)PC + 1. PCNOTE:#xxx=Loop Count NumberExpr=ExpressionFigure 6-13 Hardware DO Loop2. The stack is pushed again.A. The SP is incremented.B. The address <strong>of</strong> the first instruction in the program loop (PC) and the currentSR contents are pushed onto the SS.C. The LA register is initialized with the value specified in the DO instructiondecremented by one.-3. The LF bit in the SR is set. The LF bit is set when a program loop is inprogress and enables the end-<strong>of</strong>-Ioop detection.The program loop continues execution until the program address fetched equals the LAregister contents (last address <strong>of</strong> program loop). The contents <strong>of</strong> the LC are then testedfor one. If the LC is not one, it is decremented, and the top location in the stack RAM isread (but not pulled) into the PC to return to the start <strong>of</strong> the loop. If the LC is one, the programloop is terminated by the following sequence:1. Reading the previous LF bit from the top location in the SS into the SR2. Purging the SS (pulling the top location and discarding the contents), pullingthe LA and LC registers <strong>of</strong>f the SS, and restoring the respective registers3. Incrementing the PCThe LF bit (pulled from the SS when a loop is terminated) indicates if the terminated loopwas a nested loop. Figure 6-14 shows two DO loops, one nested inside the other. If thestack is managed to prevent a stack overflow, DO loops can be stacked indefinitely.The ENDDO instruction is not used for normal termination <strong>of</strong> a DO loop; it is only used toterminate a DO loop before the LC has been decremented to one.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!