Conversion Functions; Shift Operations - Siemens Simatic S5-101U Programming Instructions Manual

Table of Contents

Advertisement

5.2.2
Conversion functions
One's complement
The value i n accumulator
1
i s converted. The r e s u l t
can be processed i n the
accumulator.
Example
The contents o f data word
D W 64 are t o be i n v e r t e d
b i t by b i t and stored i n
data word D W 78.
STL
I
Explanation
The contents o f data word
L D W 42
D W 42 are t o be i n t e r p r e t e d
as a f i x e d - p q i n t number and
stored i n data word D W 35
w i t h i n v e r t e d sign.
Load data word D W 64 i n t o
accumulator 1 .
Form the one's complement
o f the contents o f accumula-
t o r 1 . The r e s u l t i s i n
accumulator 1.
Transfer the contents o f ac-
cumulator 1 i n t o data word
DW 78.
5.2.3
Shift operations
Load data word D W 42 i n t o
accumulator
1.
Form the two's complement o f
t h e contents o f accumulator
1 .
The r e s u l t i s i n accumulator
1.
Transfer the contents o f ac-
cumulator 1 i n t o data word D W 35.
Cperation
I
Description
I
The parameter o f t h i s
j
statement s p e c i f i e s the
number o f b i t p o s i t i o n s
by which the contents
of accumulator 1 are
s h i f t e d t o the l e f t
(SLW) o r t o the r i g h t
(SRW). Any b i t p o s i t i o n s
t h a t become f r e e when
s h i f t i n g are padded
w i t h zeros.
S L W 0 t o 15
S R W 0 t o 15
S h i f t l e f t
S h i f t r i g h t
Example
The l a s t f o u r b i t s o f the
hexadecimal number 14AFH
i n data word DW 1 are t o
be truncated and the new
hexadecimal number D14AH
r e s u l t i n g stored i n .data
word D W 3.
Note :
S h i f t operations are unconditional operations. The l a s t b i t s h i f t e d o u t can be
examined by means o f a jump operation. A jump can be made w i t h JZ i f the b i t i s
"0" and w i t h JN o r J P i f the b i t i s "1".
STL
L D W
1
S R
W
4
T D W 3
Explanation
Load data word 1 i n t o accu-
mulator 1 .
S h i f t the contents o f ac-
cumulator
1
f o u r b i t posi-
t i o n s t o the r i g h t .
The b i t p o s i t i o n s t h a t become
f r e e when s h i f t i n g are padded
w i t h zeros.
T r a n s f e r the contents o f ac-
cumulator 1 t o data word DW 3.

Advertisement

Table of Contents
loading

Table of Contents