EasyManua.ls Logo

Siemens Simatic S5-101U - Conversion Functions; Shift Operations

Siemens Simatic S5-101U
43 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
5.2.2
Conversion functions
One's complement
The value in accumulator
1
is converted. The result
can be processed in the
accumulator.
Example
The contents of data word
DW 64 are to be inverted
bit by bit and stored in
data word DW 78.
STL
I
Explanation
The contents of data word L DW 42
DW 42 are to be interpreted
as a
fixed-pqint number and
stored in data word
DW 35
with inverted sign.
Load data word
DW 64 into
accumulator
1.
Form the one's complement
of the contents of accumula-
tor
1.
The result is in
accumulator
1.
Transfer the contents of ac-
cumulator
1
into data word
DW
78.
5.2.3
Shift operations
Load data word DW 42 into
accumulator
1.
Form the two's complement of
the contents of accumulator
1.
The result is in accumulator
1.
Transfer the contents of ac-
cumulator
1
into data word DW
35.
Cperation
I
Description
I
The parameter of this
j
statement specifies the
number of bit positions
by which the contents
of
accumulator
1
are
shifted to the left
(SLW) or to the right
(SRW). Any bit positions
that become free when
shifting are padded
with zeros.
SLW
0
to 15
SRW
0
to
15
Shift left
Shift right
Example
The last four bits of the
hexadecimal number
14AFH
in data word
DW
1
are to
be truncated and the new
hexadecimal number
D14AH
resulting stored in .data
word DW 3.
Note
:
Shift operations are unconditional operations. The last bit shifted out can be
examined by means of a jump operation. A jump can be made with
JZ
if
the bit is
"0"
and with
JN
or
JP
if
the bit is
"1".
STL
L
DW
1
SR
W
4
T
DW 3
Explanation
Load data word
1
into accu-
mulator
1.
Shift the contents of ac-
cumulator
1
four bit posi-
tions to the right.
The bit positions that become
free when shifting are padded
with zeros.
Transfer the contents of ac-
cumulator
1
to data word
DW
3.

Table of Contents

Related product manuals