Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on January 23, 2021, 08:47:42 AM
-
Is there a built in way to sort an array by array position? Example: Array1[E1, E2, E3, E4] -->Array2[E4, E3, E2, E1]. I was trying to use a FIFO to store error messages but I would then like to reorder that array so that the most recent messages were at the top of an array sorted to the oldest messages.
-
No, but there is a sort posted in the program examples section.
https://forum.hosteng.com/index.php/topic,1020.0.html
-
I'm not sure what your purpose is to put them in a FIFO, as that implies you are taking them out again. I put many things into a memory block with a pointer, and then increment the pointer with a mask so it rolls over. Or use a MEMCOPY to copy 0 through 254 into 1 through 255, and insert new data into 0.
-
Reread your post, sounds like you need to do the MEMCOPY 0 through 254 to 1 through 255, then unload FIFO into spot 0.
-
Ultimately just used a for loop. An instruction that automatically sorted would be nice.