4

Subtraction (SUB)

The Subtraction function subtracts one number from another and places the result in a specified register.

number ± number =

register

46132

The numbers can be constants, as in the first subtraction shown on the facing page, or the contents of register locations in memory. For example, if R1 contains the value 100 and R4 contains the value 57, then register R3 will contain the value 43.

The second number (the number being subtracted) must be smaller than the first. Otherwise the content of the specified register will ªroll overº as shown by these examples:

1st number

2nd number

 

Total in register

100

±

10

=

90

0

±

1

=

65535

0

±

2

=

65534

The program should check to be sure that the second number is smaller than the first before subtracting.

Programming Software Instructions

1.Select Math/Move (F5).

2.Select ±SUB (F2) from the Math/Move function keys.

3.First, enter the number to be subtracted from. This can be either a constant, or a register location that will contain the number. For example: R001. Then press the Enter key.

4.Enter the number to be subtracted. This can also be a constant or a register location. Press the Enter key.

5.Enter a register location to contain the result. Press the Enter key.

4-24

Micro PLC Programmer's Guide ± April 1994

GFK-0804B

Page 65
Image 65
GE GFK-0804B manual Subtraction SUB, 1st number 2nd number Total in register