Regarding your answer near the end of this thread.
http://www.zbasic.net/forum/about1134.html
How does the multitasking overhead affect smaller generic devices? Is it included without regard to flash size or has this been changed with the introduction of the generic compiler? If so, does that answer still apply to native mode devices?dlh wrote:
Is there any way to estimate program storage requirements for VM vs. native code?
There are too many factors involved to permit even rule-of-thumb estimations. For example, consider the "null program" below that compiles to 18 bytes for the ZX-24a and 3808 bytes for the ZX-24n.
Code:
Sub Main()
End Sub
As a second data point consider the program below: ZX-24a 50 bytes, ZX-24n 3850 bytes.
Code:
Dim i as Integer, j as Integer
Sub Main()
For i = 1 to 10
j = i
Next
End Sub
Of course, the difference depends on the particular instructions used. Compare the data for the sample program below: ZX-24a 53 bytes, ZX-24n 4844 bytes.
Code:
Dim i as Integer
Sub Main()
For i = 1 to 10
Debug.Print i
Next
End Sub
The largest program that I have data for is the code for my machine tool controller comprising about 5300 lines of code and comments. This compiles to 18,070 for the ZX-24a and 30,790 for the ZX-24n. One last data point is for the RoZetta code that I have (dated June 2008). It compiles to 12,332 bytes for the ZX-40a and 40,660 bytes for the ZX-40n.
dlh wrote:
Is code written in C likely to be more efficient than ZBasic?"
For any specific routine, probably not. The C code generated from the ZBasic code is, in most cases, pretty much as you would have written it in C yourself so it then comes down to the efficiency of the code generator of the back-end compiler. The code size for a general application that doesn't exploit multi-tasking and doesn't use the RTC is probably going to be larger when written in ZBasic than if it were written in C because of the multi-tasking core infrastructure overhead that is included in every native mode ZBasic program.
Rick