Source visualisation source
In trace mode, the user can see which line of source correspond to the displayed opcode (marker >).
(Press CONTROL-V to switch between this visualisation and memory dump).
How do we find back the source line from a given address?
visu.o call's ass.o's glfp_scan_, which pretendedly performs assemblage like in phase 1 (it is dubbed phase 4).
This updates current PC (= va_pc0 + E) and line number (in DE'). When we pass target address (in BC') we are good.
As of time of writing, we convert back the current source pointer to a line number (source2line), which seems superfluous.
Well, maybe the line number (DE') housekeeping isn't accurate (TODO: check what's going on).
(Future TODO) If we want to trace inside a macro (for now the visu stays at the invocation point), we must set DE' to the corresponding macro definition line (and restore it when exiting the macro), but we don't have this information readily available.
One solution (once the target is reached) would be to rely on DE when outside a macro (immediate), and only use source2line when inside.
/!\ The fact that DE' stays at invokation line is used for count_tm which also uses phase 4.
Speeding up the process
Scanning all the source in such a fashion would be too long.
At assembly time, we store the starting $ for each source chunk (see sourcechunk).
That allows to rapidly locate the chunk containing the target address.
/!\ This scan proves deficient is there is an ORG with a lower address inside the chunk.