[NTLK] Geek Alert: NewtonOS

Matthias Melcher mm at matthiasm.com
Thu Jul 10 07:47:19 EDT 2014


To illustrate, I have put some source code up on my site. It's just informational, and as the entire project, educational, without any commercial interest whatsoever (hint o the lawyers among us ;-)

http://www.elektriktrick.com/NewtOS.html

The first block is the ARM code as can be seen by looking at the Developer ROM files that came with the native developer kit. As you can see, Apple left the "C" symbols inside the code, allowing us to understand the basic functionality and even to guess the parameters given.

It's seven command long or 28 bytes.

The second, looong block is the translation that the Just-In-Time compiler generates. Using the JIT compiler, this code is not optimized because the compiler can not see the order of commands. But writing the code out like I did here, we can generate the emulated code at compile-time instead of run-time, and the compiler can optimize somewhat. (Note that these are "C" commands, which translate sometimes into many many assembly commands.)

This is where I am at right now. I can automatically translate much of the code, and I will start doing this function by function for the Micro Kernel.

The third block, 5 lines of "C" code, is a manual translation of the original code. Compiling this will result in 28 bytes or even less of Intel or whatever machine code. Now, considering that smart phones today run their CPUs at GHz rates, we can expect an increas in speed over the MP2100 of a thousand fold.

This also explains, why the emulated NewtonOS by now runs almost as fast as the original: for one original CPU command, the emulator must run a thousand or more new commands.

Happy coding... .

 Matthias


More information about the NewtonTalk mailing list