Having time to think about this whilst driving.... :-) I thought that is would take a change to the table data model, but, I think that the compiler can iterate thought the table ( not during pre-processing ) and inspect for byte only tables and set some flag. The table being greater than 255 elements or being words code would be retained and only when only all bytes and > 255 then optimise. This could work.
You do that in GCBASIC. All the does is call fnLsL or fnLrL and this is where this started as that is not optimised code is all case ( constants are OK). ;Dim varstart = 4 ldi SysValueCopy,4 sts VARSTART,SysValueCopy ;Dim varright = varstart >> 1; // Shift right by 1 -> 00000010 (Decimal 2) lds SYSBYTETEMPB,VARSTART ldi SysValueCopy,1 sts NUMBITS,SysValueCopy rcall FN_FNLSR88 lds SysValueCopy,SYSFNLSRBYTE sts VARRIGHT,SysValueCopy ; Dim varright = 4 >> 1 ldi SysValueCopy,2 sts VARRIGHT,SysValueCopy...
:-) Not able to do changes for a while. Have a look at the change in gcbasic.bas and preprocessor. I committed. Have a go at extending. The syntax would need to default to 1, then you need to make the decision what is fastest? or is it hybrid? Is multiple instructions faster then a repeat N - end repeat cycles? You would to analyse. One shift v two shifts v repeat n: one shift: end repeat.
The project can be optmised. That is one of the fun parts of an open source project. Time is always the constraint and developers willng to analyse and make the changes.
The H does look redundant. I would need time to analyse as this code is not the code I replaced the other day. That was the preprocessor, this code generation. Thee are two cases I can think of where the code at @ASCIITAB_H is needed 1) when the destination variables is a word, or 2) the table data set contains words. Removing that ASCIITAB_H type routine would save ≈ 12–15 words of program memory on AVR.
What is in the source table? Post the that piece of the code and the variables used to index and assignment variable.
New: Revise donation handler via Ctrl-L to only save when OK ( not cancel ) is selected
That would be a 'no'. We would have to test on real silicon across 1000's of programs. Shift is a single command for clear and shift.