HP Forums
C translator for calculator project - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not remotely HP Calculators (/forum-9.html)
+--- Thread: C translator for calculator project (/thread-12929.html)

Pages: 1 2 3


RE: C translator for calculator project - Druzyek - 06-09-2019 09:31 PM

Quote:The weird thing about the Intel Decimal library is the huge tables repeated verbatim in various source files. Maybe that makes the code slightly faster, but it uses up a lot of precious space on a small, embedded system like a calculator.
That's interesting. Are you sure the compiler isn't smart enough to keep just one copy of the table?


RE: C translator for calculator project - ijabbott - 06-09-2019 10:39 PM

(06-09-2019 09:31 PM)Druzyek Wrote:  
Quote:The weird thing about the Intel Decimal library is the huge tables repeated verbatim in various source files. Maybe that makes the code slightly faster, but it uses up a lot of precious space on a small, embedded system like a calculator.
That's interesting. Are you sure the compiler isn't smart enough to keep just one copy of the table?

Typically, the different C files are compiled individually and then the resulting object files are linked. But in C speak, those tables are declared with internal linkage (declared 'static'), so are invisible to the linker, so you'd end up with multiple copies.

Some compilers have "whole program optimization" modes, which might be able to detect they are identical and combine them, in theory.


RE: C translator for calculator project - Dan - 06-20-2019 08:29 AM

After considering several options I've decided to write the C translator first. This can then be used as a basis for translators for other programming languages. See the new keypad layout and colour display here.

Here is a paper on writing a compiler, which would be interesting to try one day.