•  Back 
  •  Instruction Set 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help page 
  •  Show info about hypertext 
  •  View a new file 
Topic       : MC56001 Documentation
Author      : JAY Software
Version     : 1.0 (19/11/1997)
Subject     : Programming/Assembler
Nodes       : 152
Index Size  : 4106
HCP-Version : 4
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : 
@help       : 
@options    : -i +y +z -t4
@width      : 100
View Ref-FileENDDO                   End Current DO Loop

Operation:
    SSL(LF)->SR;SP-1->SP
    SSH->LA;SSL->LC;SP-1->SP

Assembler Syntax:
    ENDDO

Description:
    Terminate the current hardware loop before the current loop
counter (LC) equals one. If the value of the current DO loop counter
(LC) is needed, it must be read before the execution of the ENDDO
instruction. Initially, the loop flag (LF) is restored from the system
stack and the remaining portion of the status register (SR) and the
Program counter are purged from the system stack. The LA and the LC
registers are then restored from the system stack.

Restrictions:
    Due to pipelining and the fact that the ENDDO instruction accesses
the program controller registers, the ENDDO instruction must not be
immediately preceded by any of the following instructions:

Immediately before ENDDO
    MOVEC to LA, LC, SR, SSH, SSL, or SP
    MOVEM to LA, LC, SR, SSH, SSL, or SP
    MOVEP to LA, LC, SR, SSH, SSL, or SP
    MOVEC from SSH
    MOVEM from SSH
    MOVEP from SSH
    ORI MR
    ANDI MR

    Also, the ENDDO instruction cannot be the next to last(LA-1) or last
(LA) instruction in a DO loop.

Example:
        DO  Y0,NEXT             ;exec. loop ending at NEXT (Y0) times
         :
        MOVEC   LC,A            ;get current value of loop counter
        CMP     Y1,A            ;compare LC with value in Y1
        JNE     ONWARD          ;go to ONWARD ifLC not equal to Y1
        ENDDO                   ;LC equals to Y1, restore all DO registers
        JMP     NEXT            ;go to NEXT
    ONWARD:                     ;LC not equal to Y1, continue DO loop
         :                      ;(last instruction in DO loop)
    NEXT:
        MOVE    #$123456,X1     ;(first instruction AFTER DO loop)

Explanation of Example:
    This example illustrate the use of the ENDDO instruction to
terminate the current DO loop. The value of the loop counter is
compared with the value in the Y1 register to determine if execution
of the DO loop should continue. Note that the ENDDO instruction
updates certain program controller registers but does not automatically
jump past the end of the DO loop. Thus, if this action is desired, a
JMP instruction (i.e., JMP NEXT as previously shown) must be included
after the ENDDO instruction to transfer program control to the first
instruction past the end of the DO loop.

Condition Codes:
    The condition codes are not affected by this instruction.

Instruction Format:
    ENDDO

Timing:     2 oscillator clock cycles

Memory:     1 program word