I am looking to implement a diagonal searching algorithm that is continuous. This means it is one long unbroken line that is going from the top of a MxN grid and then continuously iterating until the end without jumping to calculate each diagonal.
I have been trying to figure out this algorithm but I just don't see it. I will upload images of my work below. I am trying to write this algorithm in Java or C and then I will be converting it to MIPS. I am just having trouble trying to find the actual algorithm. 

Here is an example in C to calculate the
xandycoordinates iteratively for a zigzag walk of the 2D array:Output:
Here is an alternative without an extra variable, using the parity of
x + y: