Binary arithmetic instructions, Add (addition), Sub (subtraction) – IDEC MicroSmart User Manual

Page 233: Mul (multiplication), Div (division), Inary, Rithmetic, Nstructions

Advertising
background image

« FC4A M

ICRO

S

MART

U

SER

S

M

ANUAL

»

11-1

11: B

INARY

A

RITHMETIC

I

NSTRUCTIONS

Introduction

The binary arithmetic instructions make it possible for the user to program computations using addition, subtraction, mul-
tiplication, and division. For addition and subtraction operands, internal relay M8003 is used to carry or to borrow.

The ROOT instruction can be used to calculate the square root of the value stored in a data register.

ADD (Addition)

SUB (Subtraction)

MUL (Multiplication)

DIV (Division)

Applicable CPU Modules

FC4A-C10R2/C

FC4A-C16R2/C

FC4A-C24R2/C

FC4A-D20K3/S3

FC4A-D20RK1/RS1 & FC4A-D40K3/S3

X

X

X

X

X

S1 + S2

→ D1, CY

When input is on, 16-bit data designated by source operands S1
and S2 are added. The result is set to destination operand D1
and carr y (M8003).

REP

**

S1(R)

*****

D1(R)

*****

ADD(*)

S2(R)

*****

S1 – S2

→ D1, BW

When input is on, 16-bit data designated by source operand S2
is subtracted from 16-bit data designated by source operand S1.
The result is set to destination operand D1 and borrow (M8003).

REP

**

S1(R)

*****

D1(R)

*****

SUB(*)

S2(R)

*****

S1

× S2 → D1·D1+1

When input is on, 16-bit data designated by source operand S1
is multiplied by 16-bit data designated by source operand S2.
The result is set to 32-bit data designated by destination oper-
and D1.

REP

**

S1(R)

*****

D1(R)

*****

MUL(*)

S2(R)

*****

S1 ÷ S2

→ D1 (quotient), D1+1 (remainder)

When input is on, 16-bit data designated by source operand S1
is divided by 16-bit data designated by source operand S2. The
quotient is set to 16-bit destination operand D1, and the remain-
der is set to the next 16-bit data.

When S2 is 0 (dividing by 0), the ERR LED and special internal
relay M8004 (user program execution error) are turned on.

A user program execution error also occurs in the following divi-
sion operation.

Data type I: –32768 ÷ (–1)

REP

**

S1(R)

*****

D1(R)

*****

DIV(*)

S2(R)

*****

Advertising