This paper has two aims. First, in an expository style an index theory for flows is presented, which extends the classical Morse-theory for gradient flows on manifolds. Secondly this theory is applied in the study of the forced oscillation problem of time dependent (periodic in time) and asymptotically linear Hamiltonian equations. Using the classical variational principle for periodic solutions of Hamiltonian systems a Morse-theory for periodic solutions of such systems is established. In particular a winding number, similar to the Maslov index of a periodic solution is introduced, which is related to the Morse-index of the corresponding critical point. This added structure is useful in the interpretation of the periodic solutions found. (Author).