Prepair 3D ignition retard table. RPM and some kind of EngineLoad dependent. The last may be Engine Load (g\s), Intake Manifold Pressure, Throttle Position - anything you are comfortable with and your ecu is able to report.
The simplest starting table maybe a half value of Ignition Advance table.
Look at ssm.pdf for reference.
Read RPM and Engine Load by means of SingleRead command.
Interpolate applicable ignition retard value.
Write Ignition retard value (positive value corresponds to retard in degrees) by means of SingleWrite command.
Repeat this cycle while engine is running.
If this seems to be complicated just use ecuExplorer and adjust initial ignition retard (not applicable for idle).
Some ecu's (EJ152, EJ202 NA engine for example) reset initial retard value after ignition turned off.
http://code.google.com/p/ecuexplorer/downloads/list