CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 71
Текст из файла (страница 71)
The comparisons that aremade and the corresponding bit in R that is set for each true comparison areshown below. The rest of the bits in R will be turned OFF.CB ≤ CD ≤ CB+1Bit 00CB+2 ≤ CD ≤ CB+3Bit 01CB+4 ≤ CD ≤ CB+5Bit 02CB+6 ≤ CD ≤ CB+7Bit 03CB+8 ≤ CD ≤ CB+9Bit 04CB+10 ≤ CD ≤ CB+11Bit 05CB+12 ≤ CD ≤ CB+13Bit 06CB+14 ≤ CD ≤ CB+15Bit 07CB+16 ≤ CD ≤ CB+17Bit 08CB+18 ≤ CD ≤ CB+19Bit 09CB+20 ≤ CD ≤ CB+21Bit 10CB+22 ≤ CD ≤ CB+23Bit 11CB+24 ≤ CD ≤ CB+25Bit 12CB+26 ≤ CD ≤ CB+27Bit 13CB+28 ≤ CD ≤ CB+29Bit 14CB+30 ≤ CD ≤ CB+31Bit 15FlagsER:The comparison block (i.e., CB through CB+31) exceeds the data area.Indirectly addressed DM word is non-existent. (Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)405Section 7-19Comparison InstructionsExampleThe following example shows the comparisons made and the results providedfor BCMP(68).
Here, the comparison is made during each cycle when IR 00000is ON.00000BCMP(68)HR 00DM 0010AddressInstruction0000000001LDBCMP(68)HR 00Lower limits0210Compare data in IR 001(which contains 0210) withthe given ranges.DM 0010DM 0012DM 0014DM 0016DM 0018DM 0020DM 0022DM 0024DM 0026DM 0028DM 0030DM 0032DM 0034DM 0036DM 0038DM 0040000001010201030104010501060107010801090110011101120113011401150100000HRDMLRLR 05HR 00OperandsUpper limitsDM 0011DM 0013DM 0015DM 0017DM 0019DM 0021DM 0023DM 0025DM 0027DM 0029DM 0031DM 0033DM 0035DM 0037DM 0039DM 004100001005R:LR 050100020003000400050006000700080009001000110012001300140015001600LR 0500LR 0501LR 0502LR 0503LR 0504LR 0505LR 0506LR 0507LR 0508LR 0509LR 0510LR 0511LR 0512LR 0513LR 0514LR 051500100000000000007-19-4 DOUBLE COMPARE – CMPL(60)Ladder SymbolsOperand Data AreasCp1: First word of first compare word pairCMPL(60)IR, SR, AR, DM, HR, TC, LRCp1Cp2: First word of second compare word pairCp2IR, SR, AR, DM, HR, TC, LR––Note CMPL(60) is an expansion instruction for the SRM1(-V2).
The function code 60is the factory setting and can be changed for the SRM1(-V2) if desired.LimitationsCp1 and Cp1+1 must be in the same data area.Cp2 and Cp2+1 must be in the same data area.Set the third operand to 000.DescriptionWhen the execution condition is OFF, CMPL(60) is not executed. When theexecution condition is ON, CMPL(60) joins the 4-digit hexadecimal content ofCp1+1 with that of Cp1, and that of Cp2+1 with that of Cp2 to create two 8-digithexadecimal numbers, Cp+1,Cp1 and Cp2+1,Cp2. The two 8-digit numbers arethen compared and the result is output to the GR, EQ, and LE flags in the SRarea.PrecautionsPlacing other instructions between CMPL(60) and the operation which accesses the EQ, LE, and GR flags may change the status of these flags.
Be sureto access them before the desired status is changed.406Section 7-19Comparison InstructionsFlagsER:Example:Saving CMPL(60) Results00000Indirectly addressed DM word is non-existent. (Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)GR:ON if Cp1+1,Cp1 is greater than Cp2+1,Cp2.EQ:ON if Cp1+1,Cp1 equals Cp2+1,Cp2.LE:ON if Cp1+1,Cp1 is less than Cp2+1,Cp2.The following example shows how to save the comparison result immediately. Ifthe content of HR 10, HR 09 is greater than that of DM 0001, DM 0000, then20000 is turned ON; if the two contents are equal, 20001 is turned ON; if contentof HR 10, HR 09 is less than that of DM 0001, DM 0000, then 20002 is turned ON.In some applications, only one of the three OUTs would be necessary, makingthe use of TR 0 unnecessary.
With this type of programming, 20000, 20001, and20002 are changed only when CMPL(60) is executed.TR0CMPL(60)HR 09DM 0000AddressInstruction000000000100002LDOUTCMPL(60)000030000400005000060000700008000090001025505Greater Than2550620001Equal2550720002TRHRDM---20000OperandsLess ThanANDOUTLDANDOUTLDANDOUTTRTR000000090000255052000002550620001025507200027-19-5 AREA RANGE COMPARE – ZCP(––)Operand Data AreasCD: Compare dataLadder SymbolIR, SR, AR, DM, HR, TC, LR, #ZCP(––)LL: Lower limit of rangeCDIR, SR, AR, DM, HR, TC, LR, #LLUL: Upper limit of rangeULIR, SR, AR, DM, HR, TC, LR, #LimitationsThis instruction is available in the CPM2A/CPM2C/SRM1(-V2) only.LL must be less than or equal to UL.DescriptionWhen the execution condition is OFF, ZCP(––) is not executed.
When theexecution condition is ON, ZCP(––) compares CD to the range defined by lowerlimit LL and upper limit UL and outputs the result to the GR, EQ, and LE flags inthe SR area. The resulting flag status is shown in the following table.Flag statusComparison resultCD < LLGR (SR 25505) EQ (SR 25506)00LE (SR 25507)1LL ≤ CD ≤ UL010UL < CD100407Section 7-19Comparison InstructionsPrecautionsPlacing other instructions between ZCP(––) and the operation which accessesthe EQ, LE, and GR flags may change the status of these flags. Be sure to access them before the desired status is changed.FlagsER:Indirectly addressed DM word is non-existent.
(Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)LL is greater than UL.ExampleEQ:ON if LL ≤ CD ≤ ULLE:ON if CD < LL.GR:ON if CD > UL.In the following example, the content of IR 200 (#6FA4) is compared to the range#0010 to #AB1F. Since #0010 ≤ #6FA4 ≤ #AB1F, the EQ flag and IR 10101 areturned ON.00000TR0ZCP(––)200#0010#AB1F2550501000Greater Than(above range)01001Equal(within range)01002Less Than(below range)2550625507AddressInstruction000000000100002LDOUTZCP(––)Operands000000TRANDLL: #00100010<000040000500006000070000800009000102000010AB1F25505##00003Address6CD: 200FA4<InstructionOUTLDANDOUTLDANDOUTOperands010000255060100102550701002TRTR20000: OFF20001: ON20002: OFFUL: #AB1FAB1F7-19-6 DOUBLE AREA RANGE COMPARE – ZCPL(––)Operand Data AreasLadder SymbolCD: Compare dataIR, SR, AR, DM, HR, LRZCPL(––)LL: Lower limit of rangeCDLLUL408IR, SR, AR, DM, HR, LRUL: Upper limit of rangeIR, SR, AR, DM, HR, LRSection 7-20Conversion InstructionsLimitationsThis instruction is available in the CPM2A/CPM2C only.The 8-digit value in LL+1,LL must be less than or equal to UL+1,UL.DescriptionWhen the execution condition is OFF, ZCPL(––) is not executed.
When theexecution condition is ON, ZCPL(––) compares the 8-digit value in CD, CD+1 tothe range defined by lower limit LL+1,LL and upper limit UL+1,UL and outputsthe result to the GR, EQ, and LE flags in the SR area. The resulting flag status isshown in the following table.Flag statusComparison resultGR(SR 25505)EQ(SR 25506)LE(SR 25507)CD , CD+1< LL+1,LL001LL+1,LL ≤ CD, CD+1 ≤ UL+1,UL010UL+1,UL < CD, CD+1100PrecautionsPlacing other instructions between ZCPL(––) and the operation which accessesthe EQ, LE, and GR flags may change the status of these flags.
Be sure to access them before the desired status is changed.FlagsER:Indirectly addressed DM word is non-existent. (Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)LL+1,LL is greater than UL+1,UL.EQ:LE:GR:ON if LL+1,LL ≤ CD, CD+1 ≤ UL+1,ULON if CD, CD+1 < LL+1,LL.ON if CD, CD+1 > UL+1,UL.7-20 Conversion Instructions7-20-1 BCD-TO-BINARY – BIN(23)Ladder SymbolsOperand Data AreasS: Source word (BCD)BIN(23)@BIN(23)SSRRIR, SR, AR, DM, HR, TC, LRR: Result wordIR, SR, AR, DM, HR, LRLimitationsDM 6144 to DM 6655 cannot be used for R.DescriptionWhen the execution condition is OFF, BIN(23) is not executed. When the execution condition is ON, BIN(23) converts the BCD content of S into the numericallyequivalent binary bits, and outputs the binary value to R.
Only the content of R ischanged; the content of S is left unchanged.BCDSBinaryRBIN(23) can be used to convert BCD to binary so that displays on the Programming Console or any other programming device will appear in hexadecimal rather than decimal. It can also be used to convert to binary to perform binary arithmetic operations rather than BCD arithmetic operations, e.g., when BCD andbinary values must be added.409Section 7-20Conversion InstructionsFlagsER:The content of S is not BCD.Indirectly addressed DM word is non-existent.
(Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)EQ:ON when the result is zero.7-20-2 BINARY-TO-BCD – BCD(24)Ladder SymbolsOperand Data AreasS: Source word (binary)BCD(24)@BCD(24)SSRRIR, SR, AR, DM, HR, LRR: Result wordIR, SR, AR, DM, HR, LRLimitationsIf the content of S exceeds 270F, the converted result would exceed 9999 andBCD(24) will not be executed. When the instruction is not executed, the contentof R remains unchanged.DM 6144 to DM 6655 cannot be used for R.DescriptionBCD(24) converts the binary (hexadecimal) content of S into the numericallyequivalent BCD bits, and outputs the BCD bits to R.