Swapping M3 to start of line

I am trying to create a post for RepRapFirmware for a hobby mill which does not like the standard syntax "S### M3" and wants the M at the beginning of the line. Is there any way to make this happen? I have tried an SDL in the SPINDL section of ICAM and, while it works, it breaks any time there is a CYCLE word in the APT. Here is what I have thus far. Any help is appreciated.

 

SPINDL/\$P1,\$P2(RPM,SFM,SMM),\$P3(CLW,CCLW)
IF/\$P3.EQ.CLW
  %L01=3
ELSE
  %L01=4
ENDOF/IF
INSERT/'M!(*) S!(*)',%L01,\$P1