Vertical spring with one attached mass and one unattached

If an object is attached to a spring and on top of that object another object is put (but not attached), how can the motion of the spring be described (the part that I find difficult is finding the normal force between the two objects) and when does the second object separate from the first one (after the spring was compressed enough)?
Thank you.

If an object is attached to a spring and on top of that object another object is put (but not attached), how can the motion of the spring be described (the part that I find difficult is finding the normal force between the two objects) and when does the second object separate from the first one (after the spring was compressed enough)?
Thank you.

As long as the normal force is positive, the two objects move together. Solve the equations of motion, treating the two masses as if they were one. That gives you velocity as a function of time. That, in turn, gives you acceleration as a function of time. That gives you enough information to determine the normal force. As long as the normal force is positive, your solution is valid.

Solve for the point at which the normal force becomes zero. When the normal force becomes zero you have two independent bodies. Solve for their motions independently and look for the next (or previous) event where they collide and decide how elastic the collision is.