DesertDog
Member
First, this is not a time sensitive matter so don't spend time on it you don't have! Otherwise I would apreciate any help.
In using Step 7 I find many usefull built in commands I'm used to missing. One such is a simple GE style Array Move. I curently have enough time I can look into expanding my library and knowlege by building one. I am still fairly green with STL and fall short when it comes to pointers and address registers.
This is what I'm trying to duplicate:
In the example below:
%R00001 is the first register in the source array
%R00050 is the first register in the destination array
%R00100 is the source index or offset, this is how far from the first value you want to start. With GE the value to point to first value in an array is 1 not zero.
%R00101 is the destination index or offset. See source rules.
The N here is a constant of 5 but can also be a register value. This is how many values to move from the source to the destination.
The LEN is the length of the arrays and must be set to the length of the longest of the two arrays.
So far I have come up with the following that I hope will find the source & dest datablocks and open them. Here is the STL source.
What I know about pointers I figured out doing another project people here helped with.
I know it works but I don't understand what is going on here (Code Below) and I need this operation to build a loop that moves N Bytes of data from (SR + SNX ) to (DS + DNX ). I think if I understand the pointers and addressing I can get the rest.
Thanks in advance to anyone up to this.
In using Step 7 I find many usefull built in commands I'm used to missing. One such is a simple GE style Array Move. I curently have enough time I can look into expanding my library and knowlege by building one. I am still fairly green with STL and fall short when it comes to pointers and address registers.
This is what I'm trying to duplicate:
In the example below:
%R00001 is the first register in the source array
%R00050 is the first register in the destination array
%R00100 is the source index or offset, this is how far from the first value you want to start. With GE the value to point to first value in an array is 1 not zero.
%R00101 is the destination index or offset. See source rules.
The N here is a constant of 5 but can also be a register value. This is how many values to move from the source to the destination.
The LEN is the length of the arrays and must be set to the length of the longest of the two arrays.
Code:
| _____
|%I00001 | |
|——| |———|ARRAY|—
| |_MOVE|
| |_WORD|
|%R00001—|SR DS|—%R00050
| | LEN |
| |00016|
|%R00100—|SNX |
| | |
| | |
|%R00101—|DNX |
| | |
| | |
| CONST —|N |
| 00005 |_____|
|
So far I have come up with the following that I hope will find the source & dest datablocks and open them. Here is the STL source.
Code:
FUNCTION "Array_Move_Byte" : VOID
TITLE =Move N Bytes From Source ARRAY To Dest ARRAY
VERSION : 0.1
VAR_INPUT
SR : POINTER ; // Source Array Head Address
SNX : INT ; // Source Array Index
DS : POINTER ; // Destination Array Head Address
DNX : INT ; // Destination Array Index
N : INT ; // Number Of Items To Move
END_VAR
VAR_OUTPUT
END_VAR
VAR_TEMP
SDB_Number : INT ; // Source Database Number
DDB_Number : INT ; // Destination Database Number
END_VAR
BEGIN
NETWORK
TITLE =
// Read In Pointer info
L P##SR; // Load Source Array Pointer
LAR1 ; // Into Address Register #1
L P##DS; // Load Destination Array Pointer
LAR2 ; // Into Address Register #2
// Determine & Open The Source Data Block
L W [AR1,P#0.0]; // Loads the DB Number
T #SDB_Number; // Transfer Data Block Number To Temp Area
OPN DB [#SDB_Number]; // Opens the Data Block
// Determine & Open The Destination Data Block (If not the same as Source)
L W [AR2,P#0.0]; // Loads the DB Number
T #DDB_Number; // Transfer Data Block Number To Temp Area
== I // Compare Data Block Numbers
JCN Same // Skip Open DB If Source & Dest Use The Same DB
OPN DB [#DDB_Number]; // Opens the Data Block
Same, NOP
END_FUNCTION
What I know about pointers I figured out doing another project people here helped with.
I know it works but I don't understand what is going on here (Code Below) and I need this operation to build a loop that moves N Bytes of data from (SR + SNX ) to (DS + DNX ). I think if I understand the pointers and addressing I can get the rest.
Code:
// Read Bit Data into Accumulator
L D [AR1,P#2.0]; // Loads a DWord of Data starting with BoolIn
LAR1 ; // Into Address Register 1
L D [AR1,P#0.0];
Thanks in advance to anyone up to this.