Not sure what the question is? you have the parametric formula for a circle, surley you just need to add the g-code for a square at each interval no?