IDEC MicroSmart User Manual

Page 235

Advertising
background image

11: B

INARY

A

RITHMETIC

I

NSTRUCTIONS

« FC4A M

ICRO

S

MART

U

SER

S

M

ANUAL

»

11-3

Example: SUB

• Data Type: Word

The following example demonstrates the use of special internal relay M8003 to process a borrow.

Examples: MUL

• Data Type: Word

• Data Type: Integer

Note: Since the destination uses two word operands in the multiplication operation, data register D399 (10-I/O type CPU
module) or D1299 (other CPU modules) cannot be used as destination operand D1. When using a bit operand such as inter-
nal relay for destination, 32 internal relays are required; so internal relay M281 (10-I/O type CPU module) or M1241 (other
CPU modules) or a larger number cannot be used as destination operand D1.

Examples: DIV

• Data Type: Word

• Data Type: Integer

Note: Since the destination uses two word operands in the division operation, data register D399 (10-I/O type CPU module)
or D1299 (other CPU modules) cannot be used as destination operand D1. When using a bit operand such as internal relay
for destination, 32 internal relays are required; so M281 (10-I/O type CPU module) or M1241 (other CPU modules) or a
larger number cannot be used as destination operand D1.

I0

SOTU

M8003

D12 – 7000

→ D12

To process borrowing so that the number of times
a borrow occurs is subtracted from D13.

When a borrow occurs, D13 is decremented by
one.

REP

S2 –

7000

D1 –

D12

S1 –

D12

SUB(W)

REP

S2 –

1

D1 –

D13

S1 –

D13

SUB(W)

I1

REP

S2 –

D20

D1 –

D30

S1 –

D10

MUL(W)

D10

×

300000

(000493E0h)

500

(01F4h)

600

(0258h)

D20

D30·D31

When input I1 is on, data of D10 is multiplied by data of D20, and the result is set to
D30 and D31.

D31

37856

(93E0h)

D30

4

(0004h)

I1

REP

S2 –

D20

D1 –

D30

S1 –

D10

MUL(I)

D10

×

–300000

(FFFB6C20h)

–500

(FE0Ch)

600

(0258h)

D20

D30·D31

D31

27680

(6C20h)

D30

65531

(FFFBh)

When input I2 is on, data of D10 is divided by data of D20. The quo-
tient is set to D30, and the remainder is set to D31.

I2

REP

S2 –

D20

D1 –

D30

S1 –

D10

DIV(W)

Quotient

Remainder

50

D10

÷

7

D30

7

D20

1

D31

I2

REP

S2 –

D20

D1 –

D30

S1 –

D10

DIV(I)

Quotient

Remainder

50

D10

÷

–7

D30

–7

D20

1

D31

Advertising