CNC machining simulation is the centralized embodiment of digitalization and intelligence in the development of manufacturing industry. But the existing research still has deficiencies in accuracy in the calculation of position and attitude of machine tool movement. Constraints such as command mode, acceleration and deceleration control of CNC system and geometric error of machine tool are not considered. For this issue, this paper studies the motion of five-axis machine tool simulation algorithm. Firstly, the topology, model and coordinate system of fiveaxis CNC machine tool are completely defined. Secondly, the topology structure, model and coordinate system of five-axis CNC machine tool are defined completely. On this basis, the densification of simulation of tool position and attitude based on command mode of CNC system and the corresponding time marking calculation method are explored. Combining with geometric error model of five-axis CNC machine tool, the simulation position and attitude of the model movement process of the machine tool which is more in accordance with the actual geometric state of the machine tool are obtained. The proposed algorithm is validated by topological structure modeling, tool position simulation densification and position and attitude calculation of machine tool model considering geometric errors, which proves the feasibility and validity of the algorithm.