Utilizing arrays would make this easy.
Basically, set up 4 blocks of:
50 signed 16bit WORD values called MinTemp (instead of N)
50 signed 32bit DWORD values called MinTimeStamp (these will hold 1970 Epoch values)
50 signed 16bit WORD values called MaxTemp (instead of N)
50 signed 32bit DWORD values called MaxTimeStamp (these will hold 1970 Epoch values)
If your 50 temperatures are NOT in contiguous WX memory, e.g. WX1..WX50, then you will want to create another block
50 signed 16bit WORD values called CurrTemp, then in $tTopOfScan, create a COPY instruction that copies all of the 50 various WX values into the contiguous CurrTemp (say WX1 and WX5 are your first two temperature values):
COPY WX1 to CurrTemp0, WX5 to CurrTemp1, . . . WX123 to CurrTemp49
so now you have CurrTemp block of 50 values containing ALL of the current temperature values.
Create a subroutine called CalcMinMaxTemp that you CALL from $Main called every second on EDGE
STR ST4
CALL CalcMinMaxTemp
Then in CalcMinMaxTemp, set up a FOR/NEXT loop as follows:
FOR V0 0 to 49
STRLT CurrTemp[V0] < MinTemp[V0]
MOVE CurrTemp[V0] MinTemp[V0]
MOVE DST22 MinTimeStamp[V0] // DST22 contains the local time as a 32 bit 1970 epoch value, the number of seconds since January 1, 1970
STRGT CurrTemp[V0] > MaxTemp[V0]
MOVE CurrTemp[V0] MaxTemp[V0]
MOVE DST22 MaxTimeStamp[V0]
NEXT