CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 56
Текст из файла (страница 56)
. .7-19-5 AREA RANGE COMPARE – ZCP(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-19-6 DOUBLE AREA RANGE COMPARE – ZCPL(––) . . . . . . . . . . . . . . . . . . . . . .7-20 Conversion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .7-20-1 BCD-TO-BINARY – BIN(23) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-20-2 BINARY-TO-BCD – BCD(24) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-20-3 DOUBLE BCD-TO-DOUBLE BINARY – BINL(58) . . . . . .
. . . . . . . . . . . . . . .7-20-4 DOUBLE BINARY-TO-DOUBLE BCD – BCDL(59) . . . . . . . . . . . . . . . . . . . . .7-20-5 4-TO-16 DECODER – MLPX(76) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-20-6 16-TO-4 ENCODER – DMPX(77) . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-20-7 7-SEGMENT DECODER – SDEC(78) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-20-8 ASCII CONVERT – ASC(86) . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .7-20-9 ASCII-TO-HEXADECIMAL – HEX(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-20-10 HOURS-TO-SECONDS – SEC(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-20-11 SECONDS-TO-HOURS – HMS(––) . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .7-20-12 2’S COMPLEMENT – NEG(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-21 BCD Calculation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .7-21-1 SET CARRY – STC(40) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-21-2 CLEAR CARRY – CLC(41) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-21-3 BCD ADD – ADD(30) . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .7-21-4 BCD SUBTRACT – SUB(31) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-21-5 BCD MULTIPLY – MUL(32) . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .7-21-6 BCD DIVIDE – DIV(33) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-21-7 DOUBLE BCD ADD – ADDL(54) . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .3323743743753753763763773783783793803823823823833843853853873893903913913933943964024024034044064074084094094104104114124144164194214234244254274274274274284304314327-227-237-247-257-267-277-287-297-307-21-8 DOUBLE BCD SUBTRACT – SUBL(55) . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .7-21-9 DOUBLE BCD MULTIPLY – MULL(56) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-21-10 DOUBLE BCD DIVIDE – DIVL(57) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .Binary Calculation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-22-1 BINARY ADD – ADB(50) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-22-2 BINARY SUBTRACT – SBB(51) . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-22-3 BINARY MULTIPLY – MLB(52) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-22-4 BINARY DIVIDE – DVB(53) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .Special Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-23-1 DATA SEARCH – SRCH(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-23-2 FIND MAXIMUM – MAX(––) . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .7-23-3 FIND MINIMUM – MIN(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-23-4 AVERAGE VALUE – AVG(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-23-5 SUM – SUM(––) . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Logic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-24-1 COMPLEMENT – COM(29) . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .7-24-2 LOGICAL AND – ANDW(34) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-24-3 LOGICAL OR – ORW(35) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-24-4 EXCLUSIVE OR – XORW(36) . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-24-5 EXCLUSIVE NOR – XNRW(37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Increment/Decrement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .7-25-1 BCD INCREMENT – INC(38) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-25-2 BCD DECREMENT – DEC(39) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Subroutine Instructions . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-26-1 SUBROUTINE ENTER – SBS(91) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-26-2 SUBROUTINE DEFINE and RETURN – SBN(92)/RET(93) . . . . . .
. . . . . . . . .7-26-3 MACRO – MCRO(99) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Pulse Output Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-27-1 SET PULSES – PULS(65) .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-27-2 SPEED OUTPUT– SPED(64) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-27-3 ACCELERATION CONTROL – ACC(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-27-4 PULSE WITH VARIABLE DUTY RATIO – PWM(––) . . . .
. . . . . . . . . . . . . . .7-27-5 SYNCHRONIZED PULSE CONTROL – SYNC(––) . . . . . . . . . . . . . . . . . . . . .Special Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-28-1 MESSAGE DISPLAY – MSG(46) . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-28-2 I/O REFRESH – IORF(97) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-28-3 BIT COUNTER – BCNT(67) . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .7-28-4 FRAME CHECKSUM – FCS(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Interrupt Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . .7-29-1 INTERRUPT CONTROL – INT(89) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-29-2 INTERVAL TIMER – STIM(69) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. .Communications Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-30-1 RECEIVE – RXD(47) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-30-2 TRANSMIT – TXD(48) . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-30-3 CHANGE RS-232C SETUP – STUP(––) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .434436436437437438440440441441442444446448450450451451452453453453454455455457457458458460462465467468468469470471472473475477477478480333Data Areas, Definer Values, and Flags7-1Section7-3NotationIn the remainder of this manual, all instructions will be referred to by their mnemonics. For example, the OUTPUT instruction will be called OUT; the ANDLOAD instruction, AND LD. If you’re not sure of the instruction a mnemonic isused for, refer to Appendix A Programming Instructions.If an instruction is assigned a function code, it will be given in parentheses afterthe mnemonic. These function codes, which are 2-digit decimal numbers, areused to input most instructions into the CPU Unit.
A table of instructions listed inorder of function codes is also provided in Appendix A Programming Instructions. Lists of instructions are also provided in 7-6 Instruction Tables.An @ before a mnemonic indicates the differentiated version of that instruction.Differentiated instructions are explained in Section 7-4.7-2Instruction FormatMost instructions have at least one or more operands associated with them. Operands indicate or provide the data on which an instruction is to be performed.These are sometimes input as the actual numeric values (i.e., as constants), butare usually the addresses of data area words or bits that contain the data to beused.
A bit whose address is designated as an operand is called an operand bit;a word whose address is designated as an operand is called an operand word. Insome instructions, the word address designated in an instruction indicates thefirst of multiple words containing the desired data.Each instruction requires one or more words in Program Memory. The first wordis the instruction word, which specifies the instruction and contains any definers(described below) or operand bits required by the instruction.
Other operandsrequired by the instruction are contained in following words, one operand perword. Some instructions require up to four words.A definer is an operand associated with an instruction and contained in the sameword as the instruction itself. These operands define the instruction rather thantelling what data it is to use. Examples of definers are TC numbers, which areused in timer and counter instructions to create timers and counters, as well asjump numbers (which define which Jump instruction is paired with which JumpEnd instruction).
Bit operands are also contained in the same word as theinstruction itself, although these are not considered definers.7-3Data Areas, Definer Values, and FlagsIn this section, each instruction description includes its ladder diagram symbol,the data areas that can be used by its operands, and the values that can be usedas definers. Details for the data areas are also specified by the operand namesand the type of data required for each operand (i.e., word or bit and, for words,hexadecimal or BCD).Not all addresses in the specified data areas are necessarily allowed for an operand, e.g., if an operand requires two words, the last word in a data area cannotbe designated as the first word of the operand because all words for a single operand must be within the same data area.
Other specific limitations are given in aLimitations subsection. Refer to Section 5 Memory Areas for addressing conventions and the addresses of flags and control bits.! Caution334The IR and SR areas are considered as separate data areas. If an operand hasaccess to one area, it doesn’t necessarily mean that the same operand will haveaccess to the other area. The border between the IR and SR areas can, however, be crossed for a single operand, i.e., the last bit in the IR area may be specified for an operand that requires more than one word as long as the SR area isalso allowed for that operand.SectionData Areas, Definer Values, and Flags7-3The Flags subsection lists flags that are affected by execution of an instruction.These flags include the following SR area flags.AbbreviationERCYGREQLENameInstruction Execution Error FlagCarry FlagGreater Than FlagEquals FlagLess Than FlagBit2550325504255052550625507ER is the flag most commonly used for monitoring an instruction’s execution.When ER goes ON, it indicates that an error has occurred in attempting toexecute the current instruction.