CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 76
Текст из файла (страница 76)
If normal data is being used, a negativeresult (signed binary) must be converted to normal data using NEG(––). Refer to7-20-12 2’s COMPLEMENT – NEG(––) for details.Address0000100000000010000200003CLC(41)SBB(51)InstructionLDOUTCLC(41)SBB(51)OperandsTR000011LRHR2000001200LR00HR 01In the case below, the content of LR 00 (#7A03) and CY are subtracted fromIR 002 (#F8C5). Since the result is positive, CY is 0.If the result had been negative, CY would have been set to 1.
For normal (unsigned) data, the result would have to be converted to its 2’s complement.FMi: IR 0028C5–7Su: LR 00A03–0700R: HR 01ECCY = 0(from CLC(41))02Note For signed binary calculations, the status of the UF and OF flags indicate whether the result has exceeded the signed binary data range (–32,768 (8000) to+32,767 (7FFF)).439Section 7-22Binary Calculation Instructions7-22-3 BINARY MULTIPLY – MLB(52)Operand Data AreasMd: Multiplicand word (binary)Ladder SymbolsIR, SR, AR, DM, HR, TC, LR, #MLB(52)@MLB(52)MdMdMrMrRRMr: Multiplier word (binary)IR, SR, AR, DM, HR, TC, LR, #R: First result wordIR, SR, AR, DM, HR LRLimitationsDM 6144 to DM 6655 cannot be used for R.MLB(52) cannot be used to multiply signed binary data.DescriptionWhen the execution condition is OFF, MLB(52) is not executed.
When theexecution condition is ON, MLB(52) multiplies the content of Md by the contentsof Mr, places the rightmost four digits of the result in R, and places the leftmostfour digits in R+1.MdXMrR +1FlagsRIndirectly addressed DM word is non-existent. (Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)ON when the result is 0.ER:EQ:7-22-4 BINARY DIVIDE – DVB(53)Operand Data AreasDd: Dividend word (binary)Ladder SymbolsIR, SR, AR, DM, HR, TC, LR, #DVB(53)@DVB(53)DdDdDrDrRRDr: Divisor word (binary)IR, SR, AR, DM, HR, TC, LR, #R: First result wordIR, SR, AR, DM, HR LRLimitationsDM 6144 to DM 6655 cannot be used for R.DVB(53) cannot be used to divide signed binary data.DescriptionWhen the execution condition is OFF, DVB(53) is not executed.
When theexecution condition is ON, DVB(53) divides the content of Dd by the content ofDr and the result is placed in R and R+1: the quotient in R, the remainder in R+1.QuotientRDr440DdRemainderR+1Section 7-23Special Math InstructionsFlagsER:Dr contains 0.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 0.7-23 Special Math Instructions7-23-1 DATA SEARCH – SRCH(––)Ladder SymbolsOperand Data AreasN: Number of wordsSRCH(––)@SRCH(––)NNR1R1CCIR, SR, AR, DM, HR, TC, LR, #R1: First word in rangeIR, SR, AR, DM, HR, TC, LRC: Comparison data, result wordIR, SR, AR, DM, HR, LRLimitationsThis instruction is available in the CPM2A/CPM2C only.N must be BCD between 0001 to 9999.R1 and R1+N–1 must be in the same data area.DM 6144 to DM 6655 cannot be used for C.DescriptionWhen the execution condition is OFF, SRCH(––) is not executed.
When theexecution condition is ON, SRCH(––) searches the range of memory from R1 toR1+N–1 for addresses that contain the comparison data in C. If one or more addresses contain the comparison data, the EQ Flag (SR 25506) is turned ON andthe lowest address containing the comparison data is identified in C+1. The address is identified differently for the DM area:1, 2, 3...1.
For an address in the DM area, the word address is written to C+1. For example, if the lowest address containing the comparison data is DM 0114,then #0114 is written in C+1.2. For an address in another data area, the number of addresses from the beginning of the search is written to C+1. For example, if the lowest addresscontaining the comparison data is IR 114 and the first word in the searchrange is IR 014, then #0100 is written in C+1.If none of addresses in the range contain the comparison data, the EQ Flag(SR 25506) is turned OFF and C+1 is left unchanged.FlagsER:Indirectly addressed DM word is non-existent. (Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)N is not BCD between 0001 and 9999.R1 and R1+N–1 are not in the same data area.EQ:ExampleON when the comparison data has been matched in the search range.In the following example, the 10 word range from IR 200 to IR 209 is searchedfor addresses that contain the same data as DM 0100 (89AB).
Since IR 204 con-441Section 7-23Special Math Instructionstains the same data, the EQ Flag (SR 25506) is turned ON and #0004 is writtento DM 0101.00000Address@SRCH(––)0000000001#0010200InstructionOperandsLD@SRCH(––)00000#DM 0100DMDM 010089ABIR 200IR 201IR 202IR 203IR 204IR 205IR 206IR 207IR 208IR 20912345678ABCDEF1389AB886090CD00FF89AB810COffset: 0004Offset of first word containing the search dataDM 01010010020001000004← Search data found← Search data foundNote The matching search data in IR 208 is ignored because the search data wasfound in an earlier word in the range.7-23-2 FIND MAXIMUM – MAX(––)Ladder SymbolsOperand Data AreasC: Control dataMAX(––)@MAX(––)CCR1R1DDIR, SR, AR, DM, HR, TC, LR, #R1: First word in rangeIR, SR, AR, DM, HR, TC, LRD: Destination wordIR, SR, AR, DM, HR, LRLimitationsThis instruction is available in the CPM2A/CPM2C only.N must be BCD between 0001 to 9999.R1 and R1+N–1 must be in the same data area.DM 6144 to DM 6655 cannot be used for D.DescriptionWhen the execution condition is OFF, MAX(––) is not executed.
When theexecution condition is ON, MAX(––) searches the range of memory from R1 toR1+N–1 for the address that contains the maximum value and outputs the maximum value to the destination word (D).The address is identified differently for the DM area:1, 2, 3...4421.
For an address in the DM area, the word address is written to C+1. For example, if the address containing the maximum value is DM 0114, then #0114is written in D+1.2. For an address in another data area, the number of addresses from the beginning of the search is written to D+1. For example, if the address containing the maximum value is IR 114 and the first word in the search range isIR 014, then #0100 is written in D+1.Section 7-23Special Math InstructionsIf bit 14 of C is ON and more than one address contains the same maximum value, the position of the lowest of the addresses will be output to D+1.
The positionwill be output as the DM address for the DM area, but as an absolute positionrelative to the first word in the range for all other areas.The number of words within the range (N) is contained in the 3 rightmost digits ofC, which must be BCD between 001 and 999.When bit 15 of C is OFF, data within the range is treated as unsigned binary andwhen it is ON the data is treated as signed binary.151413121100C:Number of wordsin range (N: 001 to 999 BCD)Not used – set to zero.Not used – set to zero.! CautionFlagsOutput address to D+1?1 (ON): Yes.0 (OFF): No.If bit 14 of C is ON, values above #8000 are treated as negative numbers, so theresults will differ depending on the specified data type.
Be sure that the correctdata type is specified.ER:Indirectly addressed DM word is non-existent. (Content of *DM word isnot BCD, or the DM area boundary has been exceeded.)R1 and R1+N–1 are not in the same data area.EQ:ExampleON when the maximum value is #0000.When IR 00000 is ON, the control data in DM 0000 (4010) will cause a search forthe maximum value in the 10 words starting at IR 200. The largest unsigned val-443Section 7-23Special Math Instructionsue will be stored in DM 0500.
The offset from the beginning of the search of theword containing the maximum value will be stored in DM 0501.00000MAX(––)DM 0000200AddressInstruction0000000001OperandsLDMAX(––)00000DMDM 0500DM10 wordsDM 00004010IR 2003F2AIR 20151C3IR 202E02AIR 2037C9FIR 2042A20IR 205A827IR 2062A20IR 207E02AIR 208C755IR 20994DCDM 0500E02ADM 0501000200002000500Offset of word containing maximum value: 2 wordsMaximum valueMaximum valueIf there are two words containingthe maximum value, the one foundfirst will be stored in DM 0501.7-23-3 FIND MINIMUM – MIN(––)Ladder SymbolsOperand Data AreasC: Control dataMIN(––)@MIN(––)CCR1R1DDIR, SR, AR, DM, HR, TC, LR, #R1: First word in rangeIR, SR, AR, DM, HR, TC, LRD: Destination wordIR, SR, AR, DM, HR, LRLimitationsThis instruction is available in the CPM2A/CPM2C only.N must be BCD between 0001 to 9999.R1 and R1+N–1 must be in the same data area.DM 6144 to DM 6655 cannot be used for D.DescriptionWhen the execution condition is OFF, MIN(––) is not executed.