section 7 - Index of

section 7 - Index of section 7 - Index of

11.07.2015 Views

REP Repeat Next Instruction REPOperation:Assembler Syntax:LC -+ TEMP; X:ea -+ LC REP X:eaRepeat next instruction until LC=1TEMP -+ LCLC -+ TEMP; X:aa -+ LC REP X:aaRepeat next instruction until LC=1TEMP -+ LCLC -+ TEMP; Y:ea -+ LC REP Y:eaRepeat next instruction until LC=1TEMP -+ LCLC -+ TEMP; Y:aa -+ LC REP Y:aaRepeat next instruction until LC=1TEMP -+ LCLC -+ TEMP; S -+ LC REP SRepeat next instruction until LC=1TEMP -+ LCLC -+ TEMP; #xxx -+ LC REP #xxxRepeat next instruction until LC=1TEMP -+ LCDescription: Repeat the single-word instruction immediately following the REPinstruction the specified number of times. The value specifying the number of times thegiven instruction is to be repeated is loaded into the 16-bit loop counter (LC) register.The single-word instruction is then executed the specified number of times, decrementingthe loop counter (LC) after each execution until LC=1. When the REP instruction is ineffect, the repeated instruction is fetched only one time, and it remains in the instructionregister for the duration of the loop count. Thus, the REP instruction is not Interrupt­Ible (sequential repeats are also not interruptible). The current loop counter (LC) value isstored in an internal temporary register. If LC is set equal to zero, the instruction isrepeated 65,536 times. The instruction's effective address specifies the address of thevalue which is to be loaded into the loop counter (LC). All address register indirectaddressing modes may be used. The absolute short and the immediate short addressingmodes may also be used. The four MS bits of the 12-bit immediate value are zeroed toform the 16-bit value that is to be loaded into the loop counter (LC).

REP Repeat Next Instruction REPRestrictions: The REP instruction can repeat any single-word instruction· except theREP instruction itself and any instruction that changes program flow. The followinginstructions are not allowed to follow an REP instruction:Immediately after REPDOJccJCLRJMPJSETJSccJSCLRJSRJSSETREPRTIRTSSTOPSWIWAITENDDOAlso, a REP instruction cannot be the last instruction in a DO loop (at LA). The assemblerwill generate an error if any of the previous instructions are found immediately followingan REP instruction.Example:REPXO;repeat (XO) timesMAC X1 ,Y1 ,A X:(R1 )+,X1 Y:(R4)+,Y1 ;X1 *Y1 +A ~ A, update X1 ,Y1Before ExecutionXO~' _________ $0_00_10_0 __ ~After ExecutionX0l-' _________ $0_00_1_00 __ ~LC 1-1__________ $0_00_0 __--'Lci I-~ ________ $O_O_OO __---,

REP Repeat Next Instruction REPRestrictions: The REP instruction can repeat any single-word instruction· except theREP instruction itself and any instruction that changes program flow. The followinginstructions are not allowed to follow an REP instruction:Immediately after REPDOJccJCLRJMPJSETJSccJSCLRJSRJSSETREPRTIRTSSTOPSWIWAITENDDOAlso, a REP instruction cannot be the last instruction in a DO loop (at LA). The assemblerwill generate an error if any <strong>of</strong> the previous instructions are found immediately followingan REP instruction.Example:REPXO;repeat (XO) timesMAC X1 ,Y1 ,A X:(R1 )+,X1 Y:(R4)+,Y1 ;X1 *Y1 +A ~ A, update X1 ,Y1Before ExecutionXO~' _________ $0_00_10_0 __ ~After ExecutionX0l-' _________ $0_00_1_00 __ ~LC 1-1__________ $0_00_0 __--'Lci I-~ ________ $O_O_OO __---,

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

Saved successfully!

Ooh no, something went wrong!