MCS 51 uses register tracking to optimize updating values in registers in case the new value is identical or close to the current value in the register. However, as can be seen in feature request 969, DPTR tracking with symbols and an offset, i.e something like mov dptr,#(_main_str_10000_2 + 0x0001)was not optimized to inc dptr.
; main.c:3: char __xdata str[]="12334TEST";
mov dptr,#_main_str_10000_2
mov a,#0x31
movx @dptr,a
mov dptr,#(_main_str_10000_2 + 0x0001)
inc a
#(_mainstr100002 + 0x0001) was not handled correctly by the register tracking functionality.
This patch is an attempt to fix that.
It contains the changes to the code and also the accompanying regtrack.c test is adapted.