In this paper, we present gait-generation algorithm for a four legged robot which can move in four directions: forward, backward, right and left directions. The robot can also have a combined locomotion including rotation along with each of the four mentioned movements at the same time. Stability is the other issue that we deal with in this paper. Several different methods have been developed to assess the stability of robots. In this paper, we use zero moment point (ZMP) criterion to achieve the stability for the robot. To fulfil the ZMP criterion, we restrict the movement of the robot to go along x axis. Due to the complexity of the kinematic equations for finding the ZMP location, we simplify the robot's model and also utilize the robot motion's curve analysis to determine the necessary parameters. The simulation results show the effectiveness of the design.