Is it feasible to replace DPTR loading by simple increment in cases like following one:
static void gpif_init_flowstates(void)
{
/* Clear all flowstate registers, we don't use this functionality. */
FLOWSTATE = 0;
FLOWLOGIC = 0;
FLOWEQ0CTL = 0;
FLOWEQ1CTL = 0;
FLOWHOLDOFF = 0;
FLOWSTB = 0;
FLOWSTBEDGE = 0;
FLOWSTBHPERIOD = 0;
}
actually produces:
_gpif_init_flowstates:
mov dptr,#0xE6C6
clr a
movx @dptr,a
mov dptr,#0xE6C7
movx @dptr,a
mov dptr,#0xE6C8
...
}
http://sigrok.org/gitweb/?p=sigrok-firmware-fx2lafw.git;a=blob;f=gpif-acquisition.c
This looks like something a peephole optimizer could do, provided that no flags get in the way.
Sounds like good candidate for reverse peephole rule applying (starting from last matching case).
The peephole way is still a short term solution.
Long-term is Generalized constant propagation
This could be handled by the register tracker in src/mcs51/rtrack.c. Unfortunately it currently does not support tracking the DPTR.
Are you sure?
little test:
shows that it have perfect DPTR tracking with "--fverbose-asm --peep-asm"
Funny that without "--fverbose-asm" it have no effect ;)
Last edit: Konstantin Kim 2023-02-27
O wow, I was not (no longer) aware.
But that is a mysterious bug, to only track DPTR when --fverbose-asm is used.
Should be fixed in [r13897].
Related
Commit: [r13897]
mean time "fverbose-asm" issue seems solved.
at the same time, the original question is still open
rtrack not affects c-code ;(
rtrack currently cannot track symbols.
It will never be able to track global symbols as these are not placed yet by the linker at this stage.
In this case however it could try to get the absolute address of these symbols.
Also, if the symbols were on stack, it could try to find the relative address of the symbols.
I found working workaround. Way is to avoid "__at" keyword itself:
But it may provoke mess as per it rely on preprocessor. I believe it is better anyway to treat symbols in rtrack (if is possible).
This says open, but also says
Which Win64 SDCC release should this appear in ?
Having INC DPTR for consecutive addresses would be great.
More 8051's are being released with XDATA SFRs.
Related
Commit: [r13897]
That commit [r13897] happened on the day after the 4.2.0 release. Then the ticket was closed, but it was reopened a few days later. Possibly the implemented solution does not yet apply to all scenarios?
Related
Commit: [r13897]
Last edit: Maarten Brock 2023-05-31
The reason I reopened this ticket is that rtrack could still do better as pointed out by Konstantin and as I described in
It currently only handles literals.
The bug that it only worked when -fverbose-asm was used was fixed.
It doesn't necessarily have to get the absolute addresses.
For example
Here rtrack could replace the dptr load at
(*2)with aninc dptr... if it tracked symbol + offset as well. Of course it would make the tracking code more complex.https://sourceforge.net/p/sdcc/feature-requests/969/ is basically the same thing as this here.