Condition Codes - Siemens Simatic S5-101U Programming Instructions Manual

Table of Contents

Advertisement

5.2.5
Condition codes
Generating c o n d i t i o n codes i n connection
w i t h d i g i t a l logic.
The processor o f the SIMATIC S5-101U
programable c o n t r o l l e r has three con-
d i t i o n codes:
D i g i t a l l o g i c operations r e s u l t i n the
s e t t i n g o f c o n d i t i o n codes C C 0 and
C C 1 . The overflow b i t i s n o t affected.
S e t t i n g o f the c o n d i t i o n codes depends
on the contents o f the accumulator a f t e r
the operation has been executed.
o CC 1 Value p o s i t i v e
o C C 0 Value negative
o O V F
&erflow
The condition codes are affected- by
comparison operations, a r i t h m e t i c oper-
ations, s h i f t operations and a number
o f conversion operations.
The contents o f
the accumulator
are:
Condition
codes
The f o l l o w i n g
jump oper-
a t i o n s are
executed
:
Jump
operations
Generating condition codes i n connection
w i t h comparison operations
CC1 Cc0
Zero (0000)
Not zero
The execution o f comparison operations
r e s u l t s i n the s e t t i n g o f c o n d i t i o n
codes C C 0 and C C
l .
The overflow b i t
i s not affected.
The two operands p a r t i c i p a t i n g i n a
comparison are defined as follows:
JN, JP
Example
:L
DW20 ( 1 s t operand)
:L
DW21 (2nd operand)
:!=F
(comparison operation)
Generating c o n d i t i o n codes i n connection
w i t h s h i f t operations.
The execution o f s h i f t operations r e s u l t s
i n the s e t t i n g o f C C 0 and C C 1 . The
overflow b i t i s n o t affected.
S e t t i n g o f the c o n d i t i o n codes depends
on the status o f the l a s t b i t pushed
out.
I n t h i s example, data word D W 20 i s
the 1 s t operand and data word D W 21
the 2nd operand.
Condition
codes
the 1 s t oper-
and, the 2nd
operand i s :
C C l
I
CC 0
Jump
operations
The f o l l o w i n g
jump oper-
ations are
executed :
codes
The.value o f the
l a s t b i t s h i f t e d
out i s :
Jump
operations
The f o l l o w i n g
jump opera-
t i o n s are
-
-
Equal
1 0 I
0
I J Z
Less
Greater
Note:
Comparison operations a f f e c t the r e s u l t
o f the l o g i c operation. If the c o n d i t i o n
i s satisfied,
the RLO i s "l".
I n t h i s
way, the conditional jump operation JB
can be w r i t t e n a f t e r a comparison oper-
ation.
now
Generating c o n d i t i o n codes i n connection
w i t h conversion functions.
0
1
Formation o f the two's complement (CSW)
a f f e c t s a l l c o n d i t i o n codes. This depends
on the r e s u l t o f the conversion operation:
~101
I
l
l
0
I
JN, JP
0
Generating c o n d i t i o n codes i n connection
with arithmetic operations.
1
0
I
Condition 1Jumti
JN, JM
JN, JP
0
Arithmetic operations r e s u l t i n the
s e t t i n g o f a l l condition codes. This
depends i n t u r n on the contents o f the
accumulator ( t h e r e s u l t o f the a r i t h -
metic operation).
JZ
I
codes
lop&ations
The r e s u l t a f t e r
the conversion
operation i s :
The f o l l o w i n g
jump opera-
t i o n s are
executed :
Generating c o n d i t i o n codes i n connection
w i t h f ixed-point arithmetic operation:
JN, JP, JO
Condition
I
Jump
Icodes
operations
JN. JM
JN, JP
JN. JM, JO
The r e s u l t o f
the arithmetic
operation i s :
The f o l l o w i n g
jump oper-
ations are
executed :
*)
Result o f conversion o f KH = 0000
<
-32768
-32768 t o
-
l
I
O
(
1
I
O
1
JN. JM
Notei:
The jump statement and jump d e s t i n a t i o n
must be i n the same segment. Only one
symbolic address i s permissible f o r
branch destinations i n each segment.
1
I
0
*)
Result o f the arithmetic operation:
-32768 +32768
1
JN, JP, JO

Advertisement

Table of Contents
loading

Table of Contents