happy S7 pointer

lad_stl

Member
Join Date
Dec 2013
Location
giza
Posts
19
hello every body and specially L D[AR2,P#0.0] . this is my first program using
pointers.this program is to get the maximum value in an array of data of any length.i write it as FB.i test it and it works very good.thank you again L D[AR2,P#0.0].


L #LEN //array length (input formal param.)
L -1
+I
L 0
==I
= #c_1_elem //case of one element array len.
TAK

T #LEN2 // temp address
L P##ARRAY_ADRS //pointer to array start address
LAR1
L W [AR1,P#0.0]
T #tmp_db_add

OPN DB [#tmp_db_add]
L D [AR1,P#2.0]
LAR1
L W [AR1,P#0.0]
T #temp //to carry the max value
A #c_1_elem

JC END

lmax: L #temp
+AR1 P#2.0
L W [AR1,P#0.0]
<I
JCN rr

T #temp


rr: L #LEN2
L -1
+I
T #LEN2
L 0
==I
JCN lmax

L #temp
T #MAX_VAL
BE

END: T #MAX_VAL
 
Note that if you use the FB as a multiple instance, this will not work as you have to offset the instance data access by AR2

As a rule I don't use variables names TEMP but use something more descriptive like "iMaximumSoFar"
 

Similar Topics

Hope everyone has safe travels and you get some time off, thanks for all the support and here's looking forward to next year 🍻
Replies
10
Views
551
I have not been around much but still checking in from time to time, hope everyone has a great Thanksgiving! Eat, drink and watch football, maybe...
Replies
10
Views
977
Hope everyone has a great time off if you are lucky enough to get it and safe travels! for the ones I the road..
Replies
15
Views
5,511
Happy Thanksgiving to everyone in the USA and to everyone else its our time to eat and drink like there is no tomorrow and you are also welcome to...
Replies
6
Views
2,182
Back
Top Bottom