section 7 - Index of

section 7 - Index of section 7 - Index of

11.07.2015 Views

ENDDO End Current DO Loop ENDDOOperation:SSL(LF) ~ SR;SP - 1 ~ SPSSH ~ LA; SSL ~ LC;SP -1 ~ SPAssembler Syntax:ENDDODescription: Terminate the current hardware DO loop before the current loop counter(LC) equals one. If the value of the current DO loop counter (LC) is needed, it must beread before the execution of the ENDDO instruction. Initially, the loop flag (LF) isrestored from the system stack and the remaining portion of the status register (SR) andthe program counter (PC) are purged from the system stack. The loop address (LA) andthe loop counter (LC) registers are then restored from the system stack.Restrictions: Due to pipelining and the fact that the ENDDO instruction accesses theprogram controller registers, the ENDDO instruction must not be immediately precededby any of the following instructions:Immediately before ENDDOMOVEC to LA, LC, SR, SSH, SSL, or SPMOVEM to LA, LC, SR, SSH, SSL, or SPMOVEP to LA, LC, SR, SSH, SSL, or SPMOVEC from SSHMOVEM from SSHMOVEP from SSHORIMRANDI MRREPAlso, the ENDDO instruction cannot be the last (LA) instruction in a DO loop.Example:DOYO,NEXTMOVECLC,ACMPY1,AJNE ONWARDENDDOJMP NEXTONWARDNEXT MOVE #$123456,X1;exec. loop ending at NEXT (YO) times;get current value of loop counter (LC);compare loop counter with value in Y1;go to ONWARD if LC not equal to Y1;LC equal to Y1, restore all DO registers;go to NEXT;LC not equal to Y1, continue DO loop;(Iast instruction in DO loop);(first instruction AFTER DO loop)

ENDDO End Current DO Loop ENDDOExplanation of Example: This example illustrates the use of the ENDDO instruction toterminate the current DO loop. The value of the loop counter (LC) is compared with thevalue in the Y1 register to determine if execution of the DO loop should continue. Notethat the ENDDO instruction updates certain program controller registers but does notautomatically jump past the end of the DO loop. Thus, if this action is desired, a JMPinstruction (i.e., JMP NEXT as previously shown) must be included after the ENDDOinstruction to transfer program control to the first instruction past the end of the DO loop.Condition Codes:15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0I"F I DM I T I ** I 81 I 80 I " I 10 I 8 I l I E I U N I zOpcode:23 16 15 8 7 o10 0 0 0 0 0 0 o 10 0 0 0 0 0 0 0 11 o 0 0 1 1 0 01Instruction Fields:NoneTiming: 2 oscillator clock cyclesMemory: 1 program word

ENDDO End Current DO Loop ENDDOExplanation <strong>of</strong> Example: This example illustrates the use <strong>of</strong> the ENDDO instruction toterminate the current DO loop. The value <strong>of</strong> the loop counter (LC) is compared with thevalue in the Y1 register to determine if execution <strong>of</strong> the DO loop should continue. Notethat the ENDDO instruction updates certain program controller registers but does notautomatically jump past the end <strong>of</strong> the DO loop. Thus, if this action is desired, a JMPinstruction (i.e., JMP NEXT as previously shown) must be included after the ENDDOinstruction to transfer program control to the first instruction past the end <strong>of</strong> the DO loop.Condition Codes:15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0I"F I DM I T I ** I 81 I 80 I " I 10 I 8 I l I E I U N I zOpcode:23 16 15 8 7 o10 0 0 0 0 0 0 o 10 0 0 0 0 0 0 0 11 o 0 0 1 1 0 01Instruction Fields:NoneTiming: 2 oscillator clock cyclesMemory: 1 program word

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

Saved successfully!

Ooh no, something went wrong!