CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 68
Текст из файла (страница 68)
DM 0000 acts as the stack pointer.When IR 00000 goes from OFF to ON, COLL(81) copies the content of DM 0005(DM 0000 + 5) to IR 001. The content of the stack pointer (DM 0000) is then decremented by one.00000@COLL(81)DM 0000AddressInstruction0000000001LD@COLL(81)216Operands00000DM0000216001001FlagsIR 2168005DM 0000DM 0001DM 0002DM 0003DM 0004DM 00050005AAAABBBBCCCCDDDDEEEEER:Stack pointerdecremented DM 0000DM 0001DM 0002DM 0003DM 0004DM 00050004AAAABBBBCCCCDDDDEEEEIR 001EEEEThe offset or stack length in the control word is not BCD.Indirectly addressed DM word is non-existent.
(Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)During stack operation, the value of the stack pointer exceeds thelength of the stack; an attempt was made to write to a word beyond theend of the stack.EQ:ON when the content of S is zero; otherwise OFF.7-17-8 MOVE BIT – MOVB(82)Operand Data AreasS: Source wordLadder SymbolsIR, SR, AR, DM, HR, LR, #MOVB(82)@MOVB(82)SSBiBiDDBi: Bit designator (BCD)LimitationsIR, SR, AR, DM, HR, TC, LR, #D: Destination wordIR, SR, AR, DM, HR, LRThe rightmost two digits and the leftmost two digits of Bi must each be between00 and 15.DM 6144 to DM 6655 cannot be used for Bi or D.389Section 7-17Data Movement InstructionsDescriptionWhen the execution condition is OFF, MOVB(82) is not executed. When theexecution condition is ON, MOVB(82) copies the specified bit of S to the specified bit in D.
The bits in S and D are specified by Bi. The rightmost two digits of Bidesignate the source bit; the leftmost two bits designate the destination bit.Bit15BiBiMSB 12010 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1Bit15LSBSBit001201Bit000 1 0 1 0 1 0 0 0 1 1 1 0 0 0 1Source bit (00 to 15)Bit15Destination bit (00 to 15)DFlagsER:Bit000 1 0 0 0 1 0 0 0 1 1 1 0 0 0 1Bi is not BCD, or it is specifying a non-existent bit (i.e., bit specificationmust be between 00 and 15).Indirectly addressed DM word is non-existent. (Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)7-17-9 MOVE DIGIT – MOVD(83)Operand Data AreasS: Source wordLadder SymbolsIR, SR, AR, DM, HR, TC, LR, #MOVD(83)@MOVD(83)SSDiDiDDDi: Digit designator (BCD)IR, SR, AR, DM, HR, TC, LR, #D: Destination wordIR, SR, AR, DM, HR, TC, LRLimitationsThe rightmost three digits of Di must each be between 0 and 3.DM 6144 to DM 6655 cannot be used for Di or D.DescriptionWhen the execution condition is OFF, MOVD(83) is not executed.
When theexecution condition is ON, MOVD(83) copies the content of the specified digit(s)in S to the specified digit(s) in D. Up to four digits can be transferred at one time.The first digit to be copied, the number of digits to be copied, and the first digit toreceive the copy are designated in Di as shown below.
Digits from S will be copied to consecutive digits in D starting from the designated first digit and continued for the designated number of digits. If the last digit is reached in either S or D,further digits are used starting back at digit 0.Digit number:3 2 1 0First digit in S (0 to 3)Number of digits (0 to 3)0: 1 digit1: 2 digits2: 3 digits3: 4 digitsFirst digit in D (0 to 3)Not used. (Set to 0.)390Section 7-18Data Control InstructionsThe following show examples of the data movements for various values of Di.Digit DesignatorDi: 0010Di: 0030SDSD0000111122223333SDSD0000111122223333Di: 0031FlagsER:Di: 0023At least one of the rightmost three digits of Di is not between 0 and 3.Indirectly addressed DM word is non-existent.
(Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)7-18 Data Control Instructions7-18-1 SCALING – SCL(66)Ladder SymbolsOperand Data AreasS: Source wordSCL(66)@SCL(66)SSP1P1RRIR, SR, AR, DM, HR, TC, LR, #P1: First parameter wordIR, SR, AR, DM, HR, TC, LRR: Result wordIR, SR, AR, DM, HR, LRLimitationsThis instruction is available in the CPM2A/CPM2C/SRM1(-V2) only.S must be BCD.P1 through P1+3 must be in the same data area.DM 6144 to DM 6655 cannot be used for P1 through P1+3 or R.DescriptionSCL(66) is used to linearly convert a 4-digit hexadecimal value to a 4-digit BCDvalue. Unlike BCD(24), which converts a 4-digit hexadecimal value to its 4-digitBCD equivalent (Shex → SBCD), SCL(66) can convert the hexadecimal value according to a specified linear relationship.
The conversion line is defined by twopoints specified in the parameter words P1 to P1+3.When the execution condition is OFF, SCL(66) is not executed. When the execution condition is ON, SCL(66) converts the 4-digit hexadecimal value in S to the4-digit BCD value on the line defined by points (P1, P1+1) and (P1+2, P1+3) andplaces the results in R. The results is rounded off to the nearest integer. If theresults is less than 0000, then 0000 is written to R, and if the result is greater than9999, then 9999 is written to R.391Section 7-18Data Control InstructionsThe following table shows the functions and ranges of the parameter words:ParameterFunctionRangeCommentsP1BCD point #1 (AY)0000 to 9999---P1+1Hex. point #1 (AX)0000 to FFFFDo not set P1+1=P1+3.P1+2BCD point #2 (BY)0000 to 9999---P1+3Hex.
point #2 (BX)0000 to FFFFDo not set P1+3=P1+1.The following diagram shows the source word, S, converted to D according tothe line defined by points (AY, AX) and (BY, BX).Value after(BCD)conversionBYRAYAXSValue before conversion(Hexadecimal)BXThe results can be calculated by first converting all values to BCD and then usingthe following formula.Results = BY – [(BY – AY)/(BX – AX) × (BX – S)]FlagsER:The value in P1+1 equals that in P1+3.Indirectly addressed DM word is non-existent. (Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)P1 and P1+3 are not in the same data area, or other setting error.EQ:ExampleON when the result, R, is 0000.When 00000 is turned ON in the following example, the BCD source data inDM 0100 (#0100) is converted to hexadecimal according to the parameters inDM 0150 to DM 0153.
The result (#0512) is then written to DM 0200.00000@SCL(66)DM 0100DM 0150392Instruction0000000001LD@SCL(66)Operands00000DMDMDMDM 0200DM 0150DM 0151DM 0152DM 0153Address0010000500500019010001500200DM 01000100DM 02000512Section 7-18Data Control Instructions7-18-2 SIGNED BINARY TO BCD SCALING – SCL2(––)Ladder SymbolsOperand Data AreasS: Source wordSCL2(––)@SCL2(––)SSP1P1RRIR, SR, AR, DM, HR, LRP1: First parameter wordIR, SR, AR, DM, HR, LRR: Result wordIR, SR, AR, DM, HR, LRLimitationsThis instruction is available in the CPM2A/CPM2C only.S must be BCD.P1 through P1+2 must be in the same data area.DM 6144 to DM 6655 cannot be used for R.DescriptionSCL2(––) is used to linearly convert a 4-digit signed hexadecimal value to a4-digit BCD value. Unlike BCD(24), which converts a 4-digit hexadecimal valueto its 4-digit BCD equivalent (Shex → SBCD), SCL2(––) can convert the signedhexadecimal value according to a specified linear relationship.
The conversionline is defined by the x-intercept and the slope of the line specified in the parameter words P1 to P1+2.When the execution condition is OFF, SCL2(––) is not executed. When theexecution condition is ON, SCL2(––) converts the 4-digit signed hexadecimalvalue in S to the 4-digit BCD value on the line defined by the x-intercept (P1, 0)and the slope (P1+2 ÷ P1+1) and places the results in R. The result is rounded offto the nearest integer.If the result is negative, then CY is set to 1.
If the result is less than –9999, then–9999 is written to R. If the result is greater than 9999, then 9999 is written to R.The following table shows the functions and ranges of the parameter words:ParameterFunctionRangeP1x-intercept (signed hex.)8000 to 7FFF (–32,768 to 32,767)P1+1∆X (signed hex.)8000 to 7FFF (–32,768 to 32,767)P1+2∆Y (BCD)0000 to 9999The following diagram shows the source word, S, converted to R according tothe line defined by the point (P1, 0) and slope ∆Y/∆X.Value after conversion(BCD)∆Y∆XRSValue before conversion(Signed hexadecimal)X-intercept393Section 7-18Data Control InstructionsThe result can be calculated by first converting all signed hexadecimal values toBCD and then using the following formula.R + DYDXFlagsER:(S–P1)Indirectly addressed DM word is non-existent.
(Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)P1 and P1+2 are not in the same data area, or other setting error.ExampleCY:ON when the result, R, is negative.EQ:ON when the result, R, is 0000.When 05000 is turned ON in the following example, the signed binary sourcedata in 200 (#FFE2) is converted to BCD according to the parameters inDM 0000 to DM 0002. The result (#0018) is then written to LR 00 and CY isturned ON because the result is negative.05000@SCL2(––)200DM 0000AddressInstruction0000000001LD@SCL2(––)Operands05000LR 00DMLR2DM 0000DM 0001DM 0002FFFDFFFD00030002IR 200FFE2LR 0000182000000003FFE2CY=1–0018R + 00020003+23(FFE2–FFFD)CY flag is turned ON becausethe conversion result is negative.(–1B) + –187-18-3 BCD TO SIGNED BINARY SCALING – SCL3(––)Ladder SymbolsOperand Data AreasS: Source wordSCL3(––)@SCL3(––)SSP1P1RRIR, SR, AR, DM, HR, LRP1: First parameter wordIR, SR, AR, DM, HR, LRR: Result wordIR, SR, AR, DM, HR, LRLimitations394This instruction is available in the CPM2A/CPM2C only.P1+1 must be BCD.P1 through P1+4 must be in the same data area.DM 6144 to DM 6655 cannot be used for R.Section 7-18Data Control InstructionsDescriptionSCL3(––) is used to linearly convert a 4-digit 4-digit BCD value to 4-digit signedhexadecimal.
SCL3(––) converts the BCD value according to a specified linearrelationship. The conversion line is defined by the y-intercept and the slope ofthe line specified in the parameter words P1 to P1+2.When the execution condition is OFF, SCL3(––) is not executed. When theexecution condition is ON, SCL3(––) converts the 4-digit BCD value in S to the4-digit signed hexadecimal value on the line defined by the y-intercept (0, P1)and the slope (P1+2 ÷ P1+1) and places the result in R.
The result is rounded offto the nearest integer.The content of S can be 0000 to 9999, but S will be treated as a negative value ifCY=1, so the effective range of S is actually –9999 to 9999. Be sure to set thedesired sign in CY using STC(40) or CLC(41).Parameter words P1+3 and P1+4 define upper and lower limits for the result. Ifthe result is greater than the upper limit in P1+3, then the upper limit is written toR. If the result is less than the lower limit in P1+4, then the lower limit is written toR.Note The upper and lower limits for a 12-bit Analog Input Unit would be 07FF andF800.The following table shows the functions and ranges of the parameter words:ParameterFunctionRangeP1x-intercept (signed hex.)8000 to 7FFF (–32,768 to 32,767)P1+1∆X (BCD)0001 to 9999P1+2∆Y (signed hex.)8000 to 7FFF (–32,768 to 32,767)P1+3Upper limit (signed hex.)8000 to 7FFF (–32,768 to 32,767)P1+4Lower limit (signed hex.)8000 to 7FFF (–32,768 to 32,767)The following diagram shows the source word, S, converted to R according tothe line defined by the point (0, P1) and slope ∆Y/∆X.Value after conversion(Signed hexadecimal)∆YUpper limit∆XRY-interceptValue before conversion(BCD)SLower limitThe result can be calculated by first converting all BCD values to signed binaryand then using the following formula.R+FlagsǒDYDXǓS ) P1ER:Indirectly addressed DM word is non-existent.