1 / 20

Math Instructions

Math Instructions. ADD, SUB, MUL, DIV,CLR, SQR. Arithmetic Status Bits:. The arithmetic status bits are found in word 0, bits 0-3, in the controller status file. After each math instruction is executed, the arithmetic status bits are updated as outlined in the following table:.

karen-wyatt
Download Presentation

Math Instructions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Math Instructions ADD, SUB, MUL, DIV,CLR, SQR

  2. Arithmetic Status Bits: • The arithmetic status bits are found in word 0, bits 0-3, in the controller status file. After each math instruction is executed, the arithmetic status bits are updated as outlined in the following table:

  3. Important: If the overflow bit S:0/1 is set by any math operation, the S:5/0 overflow trap bit is then set. If this bit remains set upon execution of an END, temporary end (TND) or refresh (REF) instruction, a recoverable major error code is declared. • Program an OUT with address S:5/0 between the overflow point and END, TND, or REF statement to avoid a major error.

  4. Math Register S:13 and S:14 • Changes to the math register after the following operations occur as noted below:

  5. Add (ADD):Use the ADD instruction to add on value (source A) to another value (source B) and place the result in the destination.

  6. Subtract (SUB):Use the SUB instruction to subtract one value (source B) from another (source A) and place the result in the destination.

  7. 32-Bit Addition and Subtraction: • You have the option of performing 16-bit or 32-bit signed integer addition and subtraction. This is facilitated by status file bit S:2/14 (math over flow selection bit).

  8. Multiply (MUL):Use the MUL instruction to multiply one value (source A) by another (source B) and place the result in the destination.

  9. Changes to the Math Register, S:13 and S:14 • Integer- contains the 32-bit signed integer result of the multiply operation. This result is valid at overflow. • Floating Point- the math register does not change. • Divide (DIV): • Use the DIV instruction to divide one value (source A) by another (source B). The rounded quotient is then placed in the destination. If the remainder is 0.5 or greater, round quotient is then placed in the destination. If the remainder is 0.5 or greater, round up occurs in the destination. The unrounded quotient is stored in the most significant word of the math register. The remainder is placed in the least significant word of the math register

  10. Clear (CLR) • Use the CLR instruction to set the destination value of a word to zero. Clear (CLR)

  11. Clear (CLR) • Use the CLR instruction to set the destination value of a word to zero.

  12. Square Root (SQR) • When this instruction is evaluated as true, the square root of the absolute value of the source is calculated and the rounded result is placed in the destination. • The instruction calculates the square root of a negative number without overflow or faults. In applications where the source value may be negative, use a comparison instruction to evaluate the source value to determine if the destination may be invalid.

  13. Square Root (SQR) • When this instruction is evaluated as true, the square root of the absolute value of the source is calculated and the rounded result is placed in the destination. • The instruction calculates the square root of a negative number without overflow or faults. In applications where the source value may be negative, use a comparison instruction to evaluate the source value to determine if the destination may be invalid.

More Related