Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!shelby!agate!ucbvax!cs.hull.ac.uk!rst From: rst@cs.hull.ac.uk (Rob Turner) Newsgroups: comp.sys.acorn Subject: Re: C versus ARM Message-ID: <6397.9103011248@olympus.cs.hull.ac.uk> Date: 1 Mar 91 12:48:21 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 38 John Kortink writes: > ... try writing the machinecode for Translator in C. This could result in some interesting insights. If we took a machine code program and translated every instruction into one C statement (which should be quite a simple task), and then compiled the C, what would we end up with? Let's look at some instructions (my memory is a bit rusty, because I haven't programmed in ARM code for a while): arm: mov r0, r1 C: r0 = r1 arm: add r0, r4, r6 C: r0 = r4 + r6 arm: add r1, r2, r3, lsl #4 C: r1 = r2 + (r3 << 4) A decent ARM compiler should be able to compile each of those C statements above back into one instruction (if you declared the variables r0, r1, etc to be "register"). I could envisage problems with compiling instructions which set/test condition codes efficiently. But as long as all the tests were simple (they *would* be if we were simulating machine code instructions), again, the code sequences generated would be very similar to the original. As long as all our variables were global (as in [most] machine code), and all our functions had no parameters, I find it hard to believe that the resulting compiled program would be only half the speed of the native ARM program. Surely it would be faster than that. Rob