[NTLK] MPW simulator to run ARM6asm etc.

Matthias Melcher mm at matthiasm.com
Wed Jul 24 08:51:31 EDT 2013


On 24.07.2013, at 12:14, Eckhart Köppen <lists at 40hz.org> wrote:

> I looked into something related but unfortunately didn't get very far
> either: Instead of trying to get all of MPW to run, I just wanted to
> get the C compiler to run on something more modern. The compiler is
> CFront based, but I could only find the 3.0 sources (which I even got
> to work), but not the needed 2.1 sources.

That's actually pretty cool that you made it compile!

> If you're willing to stick to C, and write custom headers and wrappers
> for the C++ code, you could use any recent GCC, and Assembly is also
> an option ;)
> 
> Eckhart

I doubt that the calling conventions are the same between gcc and Newton C. Newton expects values in Registers R0-R3, the rest on the stack. gcc IIRC, uses R0-R4, but all that changes again when you se double precission floating point which do not fit into a register, and are either paired (R0/R1) or pushed on the stack.

> PS: one more reason to hate C++...

Yes, C++ really stacks one on top of that by using per-compiler conventions for name mangling. Horror!

I invested a few evenings into the Mac simulation, and here it gets worse: we are mixing Pascal (all arguments on the stack) with fake 24 bit code (upper 8 bit of pointers are abused as flags!) with Motorola C calling conventions (pointers are in A0-A3, values are in D0-D3, unless you run out of registers...).

I got pretty far an I can now load much of the program and even run a few lines of code. But the MacOS is *filled* with horrible assumption that make coding a nightmare. For example, a handle to a memory segment is treated entirely different if its value happens to be greater than the stack pointer, in the assumptions that values greate than SP are automatically part of the stack. In a "modern" (post 1990) MMU based system, this assumption is simply wrong.

I give it three more days ;-)

 - Matthias


More information about the NewtonTalk mailing list