https://reprap.org/wiki/G-code#M98:_Call_Macro.2FSubprogram
but Fanuc and other dialects allow M97 to call a subroutine chained to the end of a program.
Because these folks always want to do the least legal thing allowed by law.
The fact that quines exist means that it must be possible to print a fully self-describing book of this sort, though it's possible that you'd require a more expressive language.
If you had a part of a machine that could save state (say.. turning on a coolant pump..) I wonder how much more of a turing machine you could wrastle into it.
(or you could just cheat and use one of the hundreds of gcode variants that have computational stuff stapled into them like the Fanuc equivalents, but that's sorta dishonest for the exercise)
Grbl, which many of the 3D printer firmwares are based on, does not (and no variables, or loops, or branching).
So suppose I attached an extruder to a Haas mill or something...