As g3n3ru5 says, writing your own G-Codes is hard for complex items. I don't recommend it if you have good, automated software available. If you don't have access to good software, however, it is entirely possible to work out G Codes by hand.

Note: I have never formally learned to write G-Codes. All I know, I reverse-engineered from my school's CNC milling machine and software. As such, everything I write is from a milling machine perspective. Oh, and I set the machine to 'Metric' mode.

CNC G-Code commands can be broadly divided into two categories, G Codes and M Codes. These may be followed (on the same line) by a number of parameters, or on a new line to repeat the command with different commands.

M codes are typically non-geometry commands, whilst G codes are typically geometry-related commands. Each is expressed as a letter followed by a number.

An example M code would be:

M6T1

This would execute M code 6, which is 'select tool', and it would select tool 1. Another command could be:

M3S1500

This would execute M code 3, which is 'Rotate cutter clockwise', and the speed is 1500Rpm

An example G code could be:

G0X10Y70

This would move the tool to 10mm on the X axis, 70mm on the Y axis. The positions are relative to the point of origin, and the tool moves at high speed (i.e. the speed used when not cutting). Another example could be:

G1Z-0.5F100

This would move the tool - at feed speed - to 0.5mm below the point of origin on the Z axis at a feed speed of 100mm/min.