Você está na página 1de 15

Funções com Acumuladores

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.1
Visão Geral das Funções com Acumuladores

 Instruções que modificam vários Acumuladores


 TAK: Troca de conteúdo entre ACCU1 e ACCU2
 PUSH: Deslocando o conteúdo dos ACCU’s para cima
 POP: Deslocando o conteúdo dos ACCU’s para baixo
 ENT: Deslocando o conteúdo dos ACCU’s para cima, sem ACCU1
 LEAVE: Deslocando o conteúdo dos ACCU’s para baixo, sem ACCU2
 Instruções aritméticas e instruções lógicas com palavras

 Instruções que modificam somente o ACCU1


 INC: Incrementa o conteúdo do ACCU 1-L-L
 DEC: Decrementa o conteúdo do ACCU 1-L-L
 CAW: Inverte a ordem dos Bytes no ACCU1-L (16 Bit)
 CAD: Inverte a ordem dos Bytes no ACCU1 (32 Bit)
 INVI, INVD: Formando complemento de um
 NEGI, NEGD, NEGR: Formando complemento de dois (Negação)
 RLDA, RRDA: Rotacionando o conteúdo do ACCU1 para direita ou
esquerda via código de condição CC1

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.2
A Instrução TAK (Troca ACCU1 com ACCU2)

S7-300:

ACCU2 V2 V1
ACCU1 V1 V2
antes TAK depois

S7-400:
ACCU4 V4 V4
ACCU3 V3 V3
ACCU2 V2 V1
ACCU1 V1 V2
antes TAK depois

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.3
As Instruções PUSH e POP

S7-300:

ACCU2 V2 V1 V2 V2
ACCU1 V1 V1 V1 V2
antes PUSH depois antes POP depois

S7-400:

ACCU4 V4 V3 V4 V4
ACCU3 V3 V2 V3 V4
ACCU2 V2 V1 V2 V3
ACCU1 V1 V1 V1 V2
antes PUSH depois antes POP depois

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.4
As Instruções ENT e LEAVE (só S7-400)

ENT:
ACCU4 V4 V3
ACCU3 V3 V2
ACCU2 V2 V2
ACCU1 V1 V1
antes depois

LEAVE:

ACCU4 V4 V4
ACCU3 V3 V4
ACCU2 V2 V3
ACCU1 V1 V1
antes depois

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.5
Instruções Aritméticas

S7-300:

ACCU2 V2 V2
ACCU1 V1 V2 op V1
antes op: +., -., *., /. depois

S7-400:
ACCU4 V4 V4
ACCU3 V3 V4
ACCU2 V2 V3
ACCU1 V1 V2 op V1
antes op: +., -., *., /. depois

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.6
Instruções Lógicas de Palavras

S7-300:

ACCU2 V2 V2
ACCU1 V1 V2 op V1
antes op: A.., O.., X.., depois

S7-400:
ACCU4 V4 V4
ACCU3 V3 V3
ACCU2 V2 V2
ACCU1 V1 V2 op V1
antes op: A.., O.., X.., depois

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.7
Instruções de Troca no ACCU1

CAW:
ACCU1-HH ACCU1-HL ACCU1-LH ACCU1-LL

V4 V3 V2 V1

V4 V3 V1 V2

CAD:

V4 V3 V2 V1

V1 V2 V3 V4

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.8
Instruções Incrementais no ACCU1

INC <const>:
ACCU1-HH ACCU1-HL ACCU1-LH ACCU1-LL

V4 V3 V2 V1

+ <const>

V4 V3 V2 V1+<const>

DEC <const>:

V4 V3 V2 V1

- <const>

V4 V3 V2 V1-<const>

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.9
Formando o Complemento de Um

INVI (Complemento de um do ACCU1-L):


31 ACCU1-H 15 ACCU1-L 0
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

31 15 0
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 (Complemento de um do ACCU1):


31 ACCU1-H 15 ACCU1-L 0
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

31 15 0
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 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.10
Negação de Números (Complemento de Dois)
NEGI (Negação de números INT)

NEGD (Negação de números DINT):


31 = 1 112 116 295 0

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

31 Complemento de um 0

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

31
Adição de + 1

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 (Negação de número REAL):


S Expoente = 8 Bit Mantissa (23 Bits) = 1.3125
23 22 0

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

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

SIMATIC S7 OUT Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.11
Instruções de Rotação em 32 Bits via Bit CC1

RLDA (Rotação esquerda via status bit CC1):


31 0
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
Bit CC1

RRDA (Rotação direita via status bit CC1):


31 0
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
Bit CC1

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.12
Exercício 2.1: Cálculo com Expoentes

Exemplo : Formação da 6ª potência de um número inteiro através de sucessivas


instruções PUSH e *I

Chave Rotativa

x y 0 0

converte BTI
para INT

ACCU1

Cópia com multiplicar


com *D ACCU1
PUSH

ACCU2

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.13
Exercício 2.2 : Troca de Dados no ACCU1

0 1 2 3 ACCU1 - L (antes)

CAW

2 3 0 1 ACCU1 - L (depois)

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.14
Exercício 2.3 : Formando Complementos

Bit 15 ACCU1-L (antes) Bit 0

1 . . . . . . . . . . . . 1 0 1

Formando o “Complemento de Um”: INVI

Bit 15 ACCU1-L (depois) Bit 0

0 . . . . . . . . . . . . 0 1 0

SIMATIC S7 Date: 07/07/21 Conhecimento em Automação


Training Center
Siemens AG 1998. All rights reserved. File: PRO2_02P.15

Você também pode gostar