Examples Of Access To Dw > 255 - Siemens CPU 948 Programming Manual

Simatic s5 s5-155u
Table of Contents

Advertisement

9.2.2
Examples of Access to
DW > 255
Example 1:
The content of data word DW 300 in DB 100 is read and transferred to flag
word FW 100 (by changing the STEP 5 operation shown in bold face, it can
also be used to read other data blocks (DB or DX)).
FB
5
SEGMENT 1
NAME :LIR DW
0005
:L
DH
0008
:L
KF
000A
:+D
000B
:
000C
:LIR
000D
:SLD
000E
:L
KF
0010
:+D
0011
:LIR
0012
:T
FW 100
0013
:BE
Example 2:
All the data words of a data block will have a constant written to them.
The program shown below writes the constant KH = A5A5 to all data words of
DB 100. After changing the STEP 5 operations shown in bold face, it can
also be used to write values to other data blocks (DB or DX). Non-existent
data blocks are detected and cause a jump to the NIVO marker.
The program uses three accumulators. Within the loop, the accumulator
contents do not change.
ACCU 1 initially contains the address of the first data word and is
incremented by one each time the loop is run through.
ACCU 2 contains the address of the last data word + 1. The loop is
terminated as soon as the content of ACCU 1 is the same as the content of
ACCU 2.
To write the data words, the operation TIR 10 is used which stores the
content of ACCU-3-L (the constant) at the address contained in ACCU 1.
ACCU contents within the loop:
ACCU 1:
address of the
ACCU 2:
address of the
ACCU 3:
constant
CPU 948 Programming Guide
C79000-G8576-C848-04
0000
Reading out DW 300 from DB 100
000E EC00
+100
1
4
+300
1
current
data word to be written to
last
data word to be written to
Memory Access via Address in ACCU 1
Start addr. of the DB list
plus the DB number
= Address list entry of DB 100
(Bits 4 to 19)
Start addr. DB 100 to ACCU 1
Convert addr. to physical addr.
DW 300 is read out
Addr. = start addr. of DB + DW addr.
Store content of DW 300 to ACCU 1
in FW 100
Continued on the next page
+ 1
9 - 15

Advertisement

Table of Contents
loading

Table of Contents