kdeadman
Member
Hello, I'm working on a S7 313C cpu and i am trying to use a pointer to grab a double integer data from a DB and move that value into the first register in that DB to be used as the output register.
i am looking for a check on my code to be sure that it will be correct or at least it should be doing what i expect it should be doing as i do not have a simulator to be able to check this.
This is a function call that I pass it a double integer from 1-115 and the DB has 116 DINTs(output is first element and 2-116 are the indexed elements). so if i need element 42 from the list i pass it 42 and it will move the data from the 42nd element into the first element.
I hope this makes sense.
K
i am looking for a check on my code to be sure that it will be correct or at least it should be doing what i expect it should be doing as i do not have a simulator to be able to check this.
Code:
OPN "75K BST CHART" // whatever DB you are using
LAR1 P#DBX 0.0 // Load address register 1 with a pointer into open DB
TAR1 MD 50 // Save address base into a DWORD for later
L #Curr_Idx // Index into the actual double integer of the DB you want
L 4 // If indexing Dwords, Reals, multiply by 4,
*D // Curr_Idx increments by 1 for each element
SLD 3 // Shift left 3 places to make offset a Pointer
LAR1 MD 50 // Load AR1 with the base pointer
+AR1 // Adds in the calculated value above to AR1
L D [AR1,P#0.0] //Loads value from register in DB into accum1
T DBD 0 //transfer our value into the first double of the DB called "output".
This is a function call that I pass it a double integer from 1-115 and the DB has 116 DINTs(output is first element and 2-116 are the indexed elements). so if i need element 42 from the list i pass it 42 and it will move the data from the 42nd element into the first element.
I hope this makes sense.
K