Page 1 of 1
Const code/data array in flash. How work with it and switch off optimization?
Posted: 13 Jun 2023 16:56
by Petr2023
Hi,
Please help )
Any directives to switch off optimization?
const's and func1() eliminated if no direct access to it.
I want access indirect to const's and func's
How organize const's to array or other structure?
const menu123 as item_t[2]=(menu,menu1)
Didn't work
Code: Select all
program Pointers
' Declarations section
typedef func_t as sub procedure
DIM aa as BYTE volatile
Sub Procedure func1()
aa=0
End Sub
dim MyPtr as ^func_t
structure item_t
dim name as char[4]
dim mm as word
dim func as word
end structure
const menu as item_t = ("123"+"a",1,@func1) code
const menu1 as item_t = ("234"+"b",2,@func1) code
const menu2 as item_t = ("345"+"c",3,@func1) code
const submenu1 as item_t = ("sub"+"d",4,@func1) code
main:
' Main program
' Z=@menu
' Z=@submenu1
end.
Each const - line with fixed width (bytes)
I want to get first line adress
Z=@menu
and then access to other lines indirect
Z=Z+8
But compiler eliminate other const's
The array is not so necessary. The compiler arranges one after the other.
But how to stop throwing out constants?
Re: Const code/data array in flash. How work with it and switch off optimization?
Posted: 14 Jun 2023 11:14
by Petr2023
Guys, this is time killing software
Re: Const code/data array in flash. How work with it and switch off optimization?
Posted: 14 Jun 2023 12:32
by Petr2023
dim MyPtr as ^func_t - not needed GREATE!!!
Wrap to ... wrap to .. wrap to ... like in "C" not needed GREATE!!!
= it can be small and fast like ASM
But a little peice of problem:
Is there any compiler directive?
For example:
Code: Select all
#DONTTOUCHITMOFO
const menu as item_t = ("123"+"¿",1,@func1) code
const menu1 as item_t = ("234"+"¿",1,@func1) code
const menu2 as item_t = ("345"+"¿",1,@func1) code
const submenu1 as item_t = ("sub"+"¿",1,@func1) code
#DONTTOUCHITMOFO END
I found a solution for functions, but for const's ...
Use the SetFuncCall directive within routine body to instruct the linker which routines can be called indirectly from that routine :
SetFunCCall (called_func[, ,...])
Volatile - no effect
External - compile error
HEEEELP
Re: Const code/data array in flash. How work with it and switch off optimization?
Posted: 14 Jun 2023 14:30
by Petr2023
So far I have found only these methods:
1. Declare array
Dim menu123 as item_t[2]
and then touch each item
menu123[0]=menu
But it generates huge code and duplicate data
2. Touch adress
Dim a as byte rx
a=@menu
....
a=@submenu1
SetFunCCall(func1)
If there is no other way, then it is very bad (very ugly code and duplicate entries + 4 bytes for each line menu)
Hmm...
Re-enable optimization (level Four) and compiler eliminate "touch"-code.
This is good, but some directive is needed for this (#DIRECTIVE).
Because it's bad to keep and show this garbage in main
Code: Select all
main:
a=@menu1
.........
...........
........
a=menu50
SetFunCCall(func1,func2, ........................................................................................func50)
Re: Const code/data array in flash. How work with it and switch off optimization?
Posted: 14 Jun 2023 15:06
by Petr2023
Guys, please make an edit especially for me with this directive
Code: Select all
#DONTTOUCHITMOFO
const menu as item_t = ("123"+"¿",1,@func1) code
const menu1 as item_t = ("234"+"¿",1,@func1) code
const menu2 as item_t = ("345"+"¿",1,@func1) code
const submenu1 as item_t = ("sub"+"¿",1,@func1) code
#DONTTOUCHITMOFOEND
Thank You
Re: Const code/data array in flash. How work with it and switch off optimization?
Posted: 21 Jun 2023 08:23
by filip
Hi,
The optimization can be switched off only in the IDE, not in the code.
Have you been able to sort out this issue ?
Regards,
Filip.
Re: Const code/data array in flash. How work with it and switch off optimization?
Posted: 21 Jun 2023 11:32
by Petr2023
filip wrote: ↑21 Jun 2023 08:23
Hi,
The optimization can be switched off only in the IDE, not in the code.
Have you been able to sort out this issue ?
Regards,
Filip.
I don't know how to do it.
Level: Zero and unchecked SSA - not work.
- optimization.png (6.84 KiB) Viewed 916 times
And the file size increases significantly.
Therefore, I would like to keep the optimization and turn it off only in some sections.
But i can't find any directive to do it
filip
Do you have corrected and supplemented documentation?
Tnx
Re: Const code/data array in flash. How work with it and switch off optimization?
Posted: 21 Jun 2023 17:17
by Petr2023
Hmmm....
Logic of MicroE
IF forum_question > 0 THEN
wait(is_user_prod_uninst)
else
IF forum_question > 1 THEN
wait(is_user_died)
END IF
END IF
But, where is profit? (no users ->no questions?)
Re: Const code/data array in flash. How work with it and switch off optimization?
Posted: 29 Jun 2023 09:15
by filip
Hi,
Sorry for the delayed answer. The optimization can be switched off only for entire code/project, not in sections.
Regards,
Filip.