Hi,
> > > > It's not too surprising that TIEmu eats lots of CPU power on a
> > > > PII 400.
> > > It eats 100% CPU even when idling around completely. Dont know
> > > what it must do more acurately when being idle. Must not even
> > > repaint the window idling.
> > In idle mode, the number of emulated instructions per unit of time
> > is lower than in full-time operation mode, but AMS still does
> > something nevertheless. To begin with, AUTO_INT_1 is fired at 256
> > Hz on HW2+ or 350+ Hz on HW1.
> You understand the inner workings of both AMS and the Emulator much
> better than me :-) But im still wondering why it takes so many cycles
> emulating a CPU that is maybe 4MIPS without FPU on a CPU+FPU which is
> at least 200MIPS... We are not simultitang that beast at transistor
> level using hopefully...
Indeed, we aren't simulating a M68000 and its peripherals at transistor
level - otherwise it would be immensely slower ;)
Among the explanations of a significant emulation cost:
* a software implementation of a foreign pipeline is costly (and very
few TI-68k programs rely on it anyway, though one of them is important);
* the x86 (IA-32) family has few usable registers (AMD alleviated that
for the x86_64 - AMD64 series), which means that virtually none of the
registers of the emulated processor can be kept into one of the host
processor's registers for any extended period of time - they have to be
read and written to memory all the time.
Most ISAs have more registers than the x86 does, which is a good thing
for programming those other processors, but bad for emulating them on an
x86. x86 and the IBM PC didn't come to dominate the processor world for
nearly two decades because they were technically better (far from
it...), but that's another story.
> I had some success today. I have ported 9 functions now. They seem
> to run after my first tests in the emulator from TI. Have not
> measured execution times on real HW compared to ASM version using
> mostly the same code until now - but i am very curious.
Your programs use many ROM_CALLs, so their speed will be mostly
dependent on AMS's speed anyway, even if the way to perform ROM_CALLs
has some impact on size and speed:
* TIFS uses F-Line ROM_CALLs, which are by far the slowest method (an
exception handling for unimplemented instructions, followed by several
dozens of instructions for turning the unimplemented instruction into a
function call), but also the smallest one;
* your TPRs request direct ROM_CALL format, which is the default value
for compatibility, but the second slowest, and the largest solution.
IOW, the worst choice for optimization (but the most compatible one)...
> But at least i save a lot of flash here: its minimum 40% less.
You can do much better on that front even if sticking to ASM programs in
the superior TIGCC/GCC4TI environment ;)
> this example i do not even share code very much between functions.
> I expect to have functions where i can save much more than 40%
> compared to the sum of the sizes of the individual statically
> linked ASM programs.
You're right that sharing some code will help reducing size, but
switching to optimized compilation options saves _far_ more, with almost
zero work :)
Case in point: I've just tried raising the minimum AMS version to 2.09
in MyLib.tpr, and switching to F-Line ROM_CALLs:
diff -Naurbp '--exclude=*.o' '--exclude=*.a' '--exclude=*.89z'
'--exclude=*.9xz' '--exclude=*.v2z' CUtils_orig/MyLib/MyLib.tpr
CUtils/MyLib/MyLib.tpr
--- CUtils_orig/MyLib/MyLib.tpr 2015-04-04 15:38:04.021741137 +0200
+++ CUtils/MyLib/MyLib.tpr 2015-04-04 15:38:42.729739518 +0200
@@ -36,10 +36,10 @@ Optimize Calc Consts=0
Use Kernel=0
Use PreOS=0
Minimum AMS Version Defined=1
-Minimum AMS Version=1.00
+Minimum AMS Version=2.09
Unofficial OS Support=0
Reloc Format=AMS
-ROM Call Format=Direct
+ROM Call Format=F-Line
BSS Ref Format=Kernel
Data Ref Format=Kernel
Use F-Line Jumps=0
Then, I recompiled MyLib, and IsFreeOf. The end result is that the
computer-side size of IsFreeOf.??z went from 2391 to 593 bytes, >75%
decrease.
I didn't try using -mregparm=5, or one of the other optimized
compilation options I mentioned in my TICT S1P9 tutorial. I didn't try
to look inside the code and perform some optimization either.
TIFS doesn't support functionality equivalent to -mregparm=5, anyway.
Five final notes:
* "float input[][]" and "_Complex float input[][]" in Stack.* do not
compile here. The more usual "float **input" and "_Complex float
**input" do, however.
* I see what you meant by having to rework complex number handling.
TIFS / Sierra C do indeed not have anything of that sort. You'll have to
significantly rework all of your code which uses complex numbers - if
you really still want to have TIFS build everything.
* a 2.09 minimum AMS version is extremely high. You should decrease that
to 2.05, as:
* you're probably not using the several AMS 2.07-2.09 ROM_CALLs
which aren't in AMS 2.05, they are barely documented anyway;
* users have a good reason to stick to 2.05 on 89 calculators:
official 2.08/2.09 spill onto one more Flash sector, and therefore
deprieve users of 64 KB of user, i.e. FlashApp + archive, memory.
* you should remove all *.o and *.dbg files before distributing CUtils,
it would reduce the size of the CUtils ZIP distribution :)
* I still strongly think you should at least investigate interworking
between TIGCC/GCC4TI and TIFS, in the hope that you can get the best of
both worlds: a FlashApp with TI-Basic extensions, while keeping the
existing code base, on which you already spent lots of time, compiled
with a much superior environment...
The conditions for testing interworking are optimal: your multiple
separate ASM programs are written under a void _main(void) function, as
all other AMS native ASM programs. Those functions are all the small
FlashApp glue code declaring TI-Basic extensions needs to see.
I'll try to cook something up for you to test. I think it would be way
too much of a shame for you to waste time rewriting some of your code to
try and cope with an inferior environment, because the interworking
between GCC4TI and TIFS wasn't investigated by anybody...
Bye,
Lionel.