Well basically the long and short of it is. The ecu is programmed by a user for set characteristics, ie power, fuel consumption etc. The program or values are remembered by the ecu in the memory. When the ecu see's say a MAP load (used for forced inducted motors, TPS is used as load for N/A) 0.5 bar at 3000rpm, it will look up that cell in the map and it may say something like 15 degrees ignition advance. Using a crank trigger the ecu is able to know where the engine is at, well No1 cylinder at TDC is what it looks for. With a dizzy setup the ecu controls the ignition coil, the charging and collapsing of the magnetic field, well basically it just turns it on and off. When the field is collapsed is when the voltage is induced into the coils secondary windings which then is sent down the plug lead, to the rotor arm, to the contact point, down the corresponding cylinder lead to the spark plug. After ignition has happened, or during if the engine knocks/pings the knock sensor picks up on this and will then reduce the ignition advance for the next cylinder. Basically it just uses its predefined user programmed values, but then uses the various sensors to keep it running at its optimum. Open and closed loom control is another topic lol.