A slicer (a pc program) defines how the movement should be done. You provide a 3d model (an stl file) to a slicer and the slicer generates G-code which defines how the printer will move. The printer firmware interprets the G-code.
An example of a source code of one of the slicers: [github.com]
Here you can read about G-code: [reprap.org]
An example of a source code of one of the slicers: [github.com]
Here you can read about G-code: [reprap.org]