Almost
Charmer, I agree with Paul. This can't be an accurate transaltion, but it looks to me like it is copying 32 bit values from and address in #LADDR ( LONG ADDRESS, WITH DB and OFFSET? ) to an address initially pointed to AR2. AR2 get used as a source pointer later in the code.
The register #BYTES controls the number of 32 bit transfers, not the number of bytes transfered.
PLucas said:
Charmer,
I might be able to help you on this, but I am not convinced that what you have posted is exactly what's in the program.
Also what does the PLC control that this code is taken from?
I will try and explain a few bits of the code for you
L DIW [AR2,P#8.0]
that means Load Data block Input Word
AR2 is Accumalative Register 2 P#8.0 will load a 32bit pointer into the address specified
Paul
This LOADS a value, pointed to by AR2+8, into the accumulator.
ARX is an ADDRESS REGISTER. In your case, address register 2.
I also have my doubts about DIW. I think DI is data instance. There are two Data Block Registers that specify which data areas are accessible at that time and you must chose between them by specifying DBW or DIW. I/O us ccessed using the P.
In Siemens STL the addressing mode [ARX,P#XX.X] can be used in two ways.
1. The P#XX.X can be an array address in the current data block and ARX can used as a index into the array.
2. A pointer to a record or structure can be loaded into ARX. The P#XX.X can be used as an offset to access different field of a record such as name, rank and serial number. Name would have an offset of 0 so it would use [ARX,P#0.0]. The rank would be offset by the number of allowable characters in the name. Lets say 20 so to access the rank one would use [ARX,p#20.0]. Serial number would be att offset 24 from the beginning of the name so the serial number would used [ARX,P#24.0]
Siemens makes complex addressing easy. It is too bad that P#XX.X can't be a literal that is compiled so I can used [ARX,P#Name],[ARX,P#Rank] and [ARX,P#Serial]. This would be more self documenting and much easier to maintain. Just think of what happens if I didn't allocate enough characters for the name and I must expand name field to 32 characters. Now I must change the hard coded offset for Rank and Serial Number everywhere ( all changes should be in just one file if you wrote the code right) in the program. That is a lot of work and is error prone. Hopefully Siemens will fix this in the future.