You are on page 1of 15

Accumulator Functions

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_02E.1

SITRAIN Training for


Automation and Drives

Overview of the Accumulator Functions


Instructions, that affect several Accumulators

TAK: Toggle (swap) the contents of ACCU1 and ACCU2


PUSH: Shifting the ACCU contents "upward"
POP: Shifting the ACCU contents "downward"
ENT: Shifting the ACCU contents "upward", without ACCU1
LEAVE: Shifting the ACCU contents "downward", without ACCU2
Arithmetic Instructions and Word Logic Instructions

Instructions, that only affect ACCU1

INC: Increment the contents of ACCU1-LL


DEC: Decrement the contents of ACCU1-LL
CAW: Reverse the order of the bytes in ACCU1-L
CAD: Reverse the order of the bytes in ACCU1
INVI, INVD: Forming the ones complement
NEGI, NEGD, NEGR: Forming the twos complement (Negation)
SLW, SLD, SRW, SRD, SSI, SSD: Shift the contents of ACCU1 word-byword or doubleword-by-doubleword to the left or the right
RLD, RRD: Rotate the contents of ACCU1 to the left or to the right
RLDA, RRDA: Rotate the contents of ACCU1 to the left or to the right
via the condition code bit CC1

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_02E.2

SITRAIN Training for


Automation and Drives

The Instruction TAK (Toggle ACCU1 and ACCU2)


S7-300:
ACCU2
ACCU1

V1
V2

V2
V1
before

after

TAK

S7-400:
ACCU4
ACCU3
ACCU2

ACCU1

before

SIMATIC S7
Siemens AG 2001. All rights reserved.

V4
V3
V1
V2

V4
V3
V2
V1
TAK

Date:
File:

09.01.2015
PRO2_02E.3

after

SITRAIN Training for


Automation and Drives

The Instructions PUSH and POP


S7-300:

ACCU2
ACCU1

before

PUSH

V2
V2

V2
V1

V1
V1

V2
V1

after

before

POP

after

S7-400:
ACCU4
ACCU3
ACCU2
ACCU1

V4
V3
V2
V1
before

SIMATIC S7
Siemens AG 2001. All rights reserved.

PUSH

V3
V2
V1
V1

V4
V3
V2
V1

after

before

Date:
File:

09.01.2015
PRO2_02E.4

V4
V4
V3
V2
POP

after

SITRAIN Training for


Automation and Drives

The Instructions ENT and LEAVE (only S7-400)


ENT:
ACCU4
ACCU3
ACCU2
ACCU1

V3
V2
V2
V1

V4
V3
V2
V1
before

after

LEAVE:
ACCU4
ACCU3
ACCU2
ACCU1

V4
V4
V3
V1

V4
V3
V2
V1
before

SIMATIC S7
Siemens AG 2001. All rights reserved.

after

Date:
File:

09.01.2015
PRO2_02E.5

SITRAIN Training for


Automation and Drives

Arithmetic Instructions
S7-300:
ACCU2
ACCU1

V2
V2 op V1

V2
V1
op: +., -., *., /.

before

after

S7-400:
ACCU4
ACCU3
ACCU2

ACCU1

V4
V4
V3
V2 op V1

V4
V3
V2
V1
before

SIMATIC S7
Siemens AG 2001. All rights reserved.

op: +., -., *., /.

Date:
File:

09.01.2015
PRO2_02E.6

after

SITRAIN Training for


Automation and Drives

Word Logic Instructions


S7-300:
ACCU2
ACCU1

V2
V2 op V1

V2
V1
before

op: A.., O.., X..,

after

S7-400:
ACCU4
ACCU3
ACCU2

ACCU1

before

SIMATIC S7
Siemens AG 2001. All rights reserved.

V4
V3
V2
V2 op V1

V4
V3
V2
V1
op: A.., O.., X..,

Date:
File:

09.01.2015
PRO2_02E.7

after

SITRAIN Training for


Automation and Drives

Change Instructions for ACCU1


CAW:

ACCU1-HH

ACCU1-HL

ACCU1-LH

V4

V3

V2

V1

V4

V3

V1

V2

V4

V3

V2

V1

V1

V2

V3

V4

ACCU1-LL

CAD:

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_02E.8

SITRAIN Training for


Automation and Drives

Increment Instructions for ACCU1


INC <const>:

ACCU1-HH
V4

ACCU1-HL
V3

ACCU1-LH
V2

ACCU1-LL
V1
+ <const>

V4

V3

V2

V1+<const>

V4

V3

V2

V1

DEC <const>:

- <const>

V4

SIMATIC S7
Siemens AG 2001. All rights reserved.

V3

Date:
File:

V2

09.01.2015
PRO2_02E.9

V1-<const>

SITRAIN Training for


Automation and Drives

Forming the Ones Complement


INVI (Ones Complement of ACCU1-L):
31

ACCU1-H

15

ACCU1-L

0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 1 1 0 0 0 1 1 0 0 0 1 0 0 0 1 1 1

15

31

0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 1 1 1 0 0 1 1 1 0 1 1 1 0 0 0

INVD (Ones Complement of ACCU1):


31

ACCU1-H

15

ACCU1-L

0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 1 1 0 0 0 1 1 0 0 0 1 0 0 0 1 1 1
15

31

1 0 1 1 1 1 0 1 1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 1 1 0 1 1 1 0 0 0

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_02E.10

SITRAIN Training for


Automation and Drives

Negation of Numbers (Twos Complement)


NEGI (Negation of INT numbers)
NEGD (Negation of DINT numbers):
= 1 112 116 295

31

0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 1 1 0 0 0 1 1 0 0 0 1 0 0 0 1 1 1
Ones Complement 0

31

1 0 1 1 1 1 0 1 1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 1 1 0 1 1 1 0 0 0
Addition of +

31

1 0 1 1 1 1 0 1 1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 1 1 0 1 1 1 0 0 1

NEGR (Negation of REAL numbers):


S

Exponent = 8 Bit

Mantissa (23 Bits)

= 1.3125
0

23 22

0 0 1 1 1 1 1 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 1 1 1 1 1 1 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_02E.11

SITRAIN Training for


Automation and Drives

32 Bit Rotate Instructions via CC1 Bit

RLDA (Rotate left via status bit CC1):


31

0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ACCU1
CC1 Bit

RRDA (Rotate right via status bit CC1):


31

0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ACCU1
CC1 Bit

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_02E.12

SITRAIN Training for


Automation and Drives

Exercise 2.1: Calculation of Exponents


Example: Forming the 6th power of an integer through successive
use of PUSH and *I

Pushwheel button
x
convert to
INT

BTI

ACCU1
multiply
by *I

Copy
with PUSH

ACCU1

ACCU2

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_02E.13

SITRAIN Training for


Automation and Drives

Exercise 2.2 : Data Exchange in ACCU1

ACCU1 - L (before)

CAW

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_02E.14

ACCU1 - L (after)

SITRAIN Training for


Automation and Drives

Exercise 2.3 : Forming Complements


ACCU1-L (before)

Bit 15
1

Bit 0
.

Forming the Ones


Complement: INVI

ACCU1-L (after)

Bit 15
0

SIMATIC S7
Siemens AG 2001. All rights reserved.

Date:
File:

09.01.2015
PRO2_02E.15

Bit 0
.

SITRAIN Training for


Automation and Drives

You might also like