## Pré-visualização | Página 30 de 50

)–––––+ | | | |Source A N7:11| 1 | | | | | 0| | | | | |Source B 102| | | | | | | | | | | +––––––––––––––––––+ | | | | 1/4” change | | | | Thousands drill bit | | | | NOW | | | | +GEQ–––––––––––––––+ O:3.0 | | | +–+GRTR THAN OR EQUAL+–––––––––––––––––––––––––––––––––––––––( )–––––+ | | | |Source A N7:11| 6 | | | | | 0| | | | | |Source B 105| | | | | | | | | | | +––––––––––––––––––+ | | | | 100,000 |102,000 change | | | | 1/4” |1/4” drill | | | | increments|increments bit | | | | have |have soon | | | | occurred |occurred | | | | B3:1 B3:1 O:3.0 | | | +–+–––––––––––––––––––––––] [––––––––]/[––––––––––––––––+––––( )–––––+ | | | 0 1 | 4 | | | 100,000 |102,000 |1.28 | | | | 1/4” |1/4” |second | | | | increments|increments|free | | | | have |have |running | | | | occurred |occurred |clock bit | | | | B3:1 B3:1 S:4 | | | +–––––––––––––––––––––––] [––––––––] [––––––––] [–––––+ | | 0 1 7 | Math Instructions 3–1 3 Math Instructions This chapter contains general information about math instructions and explains how they function in your logic program. Each of the math instructions includes information on: • what the instruction symbol looks like • how to use the instruction In addition, the last section contains an application example for a paper drilling machine that shows the math instructions in use. Math Instructions Instruction Purpo e Pa e Mnemonic Name Purpose Page ADD Add Adds source A to source B and stores the result in the destination. 3–6 SUB Subtract Subtracts source B from source A and stores the result in the destination. 3–6 MUL Multiply Multiplies source A by source B and stores the re- sult in the destination. 3–10 DIV Divide Divides source A by source B and stores the result in the destination and the math register. 3–11 DDV Double Divide Divides the contents of the math register by the source and stores the result in the destination and the math register. 3–12 CLR Clear Sets all bits of a word to zero. 3–13 SQR Square Root Calculates the square root of the source and places the integer result in the destination. 3–13 SCP Scale with Parameters Produces a scaled output value that has a linear relationship between the input and scaled values. 3–14 continued on next page PrefaceInstruction Set Reference Manual 3–2 Instruction Purpo e Pa e Mnemonic Name Purpose Page SCL Scale Data Multiplies the source by a specified rate, adds to an offset value, and stores the result in the destination. 3–17 ABS Absolute Calculates the absolute value of the source and places the result in the destination. 3–24 CPT Compute Evaluates an expression and stores the result in the destination. 3–25 SWP Swap Swaps the low and high bytes of a specified number of words in a bit, integer, ASCII, or string file. 3–27 ASN Arc Sine Takes the arc sine of a number and stores the result (in radians) in the destination. 3–28 ACS Arc Cosine Takes the arc cosine of a number and stores the result (in radians) in the destination. 3–28 ATN Arc Tangent Takes the arc tangent of a number and stores the result (in radians) in the destination. 3–29 COS Cosine Takes the cosine of a number and stores the result in the destination. 3–29 LN Natural Log Takes the natural log of the value in the source and stores it in the destination. 3–30 LOG Log to the Base 10 Takes the log base 10 of the value in the source and stores the result in the destination. 3–30 SIN Sine Takes the sine of a number and stores the result in the destination. 3–31 TAN Tangent Takes the tangent of a number and stores the result in the destination. 3–31 XPY X to the Power of Y Raise a value to a power and stores the result in the destination. 3–32 Math Instructions 3–3 About the Math Instructions The majority of the instructions take two input values, perform the specified arithmetic function, and output the result to an assigned memory location. For example, both the ADD and SUB instructions take a pair of input values, add or subtract them, and place the result in the specified destination. If the result of the operation exceeds the allowable value, an overflow or underflow bit is set. To learn more about the math instructions, we suggest that you read the Math Instructions Overview that follows. Math Instructions Overview The following general information applies to math instructions. Entering Parameters • Source is the address(es) of the value(s) on which the mathematical, logical, or move operation is to be performed. This can be word addresses or program constants. An instruction that has two source operands does not accept program constants in both operands. • Destination is the address of the result of the operation. Signed integers are stored in two’s complementary form and apply to both source and destination parameters. When using either an SLC 5/03 (OS301 and higher), SLC 5/04, or SLC 5/05 processor; floating point and string values (specified at the word level) are supported. Refer to appendix E for additional valid addressing types. Using Indexed Word Addresses You have the option of using indexed word addresses for instruction parameters specifying word addresses (except for fixed and SLC 5/01 processors). Indexed addressing is discussed in appendix F. PrefaceInstruction Set Reference Manual 3–4 Using Indirect Word Addresses You have the option of using indirect word-level and bit-level addresses for instructions specifying word addresses when using an SLC 5/03 (OS302), SLC 5/04 (OS401), or SLC 5/05 processors. See appendix C for more information. Updates to Arithmetic Status Bits The arithmetic status bits are found in Word 0, bits 0–3 in the controller status file. After an instruction is executed, the arithmetic status bits in the status file are updated: With this Bit: The Controller: S:0/0 Carry (C) sets if carry is generated; otherwise cleared. S:0/1 Overflow (V) indicates that the actual result of a math instruction does not fit in the designated