comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <eachus@mitre.org>
Subject: Re: Compiler for Z80/6510
Date: 1999/12/02
Date: 1999-12-02T21:13:20+00:00	[thread overview]
Message-ID: <3846E271.EC40F07C@mitre.org> (raw)
In-Reply-To: 1999Dec2.080628.1@eisner

Larry Kilgallen wrote:
  
> Let me give a counter-example.  Macro-64 on Alpha VMS certainly does
> not contain anything specific to versions of the architecture not yet
> designed :-), but it does allow you to specify your own instruction
> definitions, so any possible bit combination for an instruction is
> attainable.
 
    And the original assembler for the PDP-1, not only allowed you to do
this, but I have a copy of some code arond here somewhere which not only
did this, but used it to call instructions I had added to a particular
PDP-1.  (Actually, the PDP-1 MACRO assembler was so powerful that the
PDP-6 MACRO assembler was originally writen using it.)  The PDP-11/60,
and I think some other PDP-11 models had user programmable microcode so
that you didn't have to modify the hardware to add your favorite
instructions.  I've also had compilers generate self-modifying code. 
For example, the code includes jumps to run-time routines to do integer
multiply and divide, but if this machine has hardware to do those, then
the run-time routine back-patches the executable image so that it is not
called again.

    All very fancy tricks, but sort of beside the point, but your
mention of Macro-64 brought back memories...

    In any case,  I think that Robert Dewar's position is an expert
programmer can do anything that the compiler can do--after all if it is
in the compiler someone had to think of it first.  So such a programmer
can always do better than the compiler.

    However, I have run into several counterexamples.  My favorite came
during the early days of Ada.  A programmer--I'll call him Joe--called
up and said that our compiler was generating incorrect code, so I asked
him to send me the source.
After studying his over a page long example for a while, I called back
and suggested a two line replacement.  His incredulous comment was, "You
can do that in Ada?"  He promised to call me back if it didn't work.

    A few minutes later, he called back.  "I get exactly the same code,"
he said, "and you can't do that in three instructions--it takes four." 
So I printed an assembly listing and looked at it.

    "Looks perfectly fine to me.  The first instruction reads the offset
from the first argument on the stack and post-decrements the stack
pointer.  The second instruction indirects through the second argument
on the stack, adding the offset it just read into a register.  The third
instruction preincrements the stack pointer, and then returns."

    Joe was flabergasted.  He went off to check, and sure enough the
compiler generated code did beat the code he had discovered years
earlier.  I agree, never in a million years would I have thought of
post-incrementing and pre-incrementing the stack pointer, especially in
the RETURN instruction, but it was legal.  And since the index had been
statically verified, there was no concern about an exception occuring in
the middle.  Score one for peephole optimization.

    This was on Honeywell equipment, but the BLISS-11 compiler had a
peephole optimizer that was even more agressive, but could take hours to
compile a few lines of code.  (Yes, the process was NP-time, but it was
usually only used on tight loops and on frequently called routines that
were part of the operating system or compiler run-times.)  Using
BLISS-11 on such inner loops, I was amazed at how often it discovered
tricks that I would never have thought of.  (For those unfamiliar with
the PDP series of machines, the PDP-1 was an 18-bit single address
architecture, the PDP-11 was a 16-bit two (register) address
architecture using a register array, and the PDP-6, with 36-bit word and
15-bit addresses had a mix, mostly one-address instructions, with some
two address instructions, some one plus register, some two register
instructions, and finally a couple of two address conditional branches.)
 
-- 

                                        Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




  reply	other threads:[~1999-12-02  0:00 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-24  0:00 Compiler for Z80/6510 Lutz Donnerhacke
1999-11-24  0:00 ` Wil
1999-11-25  0:00   ` Lutz Donnerhacke
1999-11-25  0:00     ` Robert Dewar
1999-11-25  0:00       ` Peter Milliken
1999-11-26  0:00         ` Ed Falis
1999-11-26  0:00           ` Robert C. Leif, Ph.D.
1999-11-27  0:00             ` Florian Weimer
1999-11-28  0:00             ` Robert Dewar
     [not found]             ` <01bf38cb$be9b2b60$022a6282@dieppe>
1999-11-28  0:00               ` Robert Dewar
1999-11-28  0:00                 ` Robert A Duff
1999-11-30  0:00                 ` Pascal Obry
1999-12-06  0:00           ` Richard D Riehle
1999-11-26  0:00         ` Robert Dewar
1999-11-26  0:00           ` Robert A Duff
1999-11-27  0:00             ` Robert Dewar
1999-12-01  0:00             ` Robert I. Eachus
1999-12-02  0:00               ` Larry Kilgallen
1999-12-02  0:00                 ` Robert I. Eachus [this message]
1999-12-03  0:00               ` Robert Dewar
1999-12-03  0:00                 ` Robert I. Eachus
1999-12-06  0:00                   ` Robert Dewar
1999-12-13  0:00                     ` Robert I. Eachus
1999-12-13  0:00                       ` carr_tom
1999-12-17  0:00                         ` Robert I. Eachus
1999-12-19  0:00                       ` Robert Dewar
1999-12-21  0:00                         ` Robert I. Eachus
1999-12-23  0:00                           ` Robert Dewar
1999-12-23  0:00                             ` Robert I. Eachus
1999-11-26  0:00         ` Tarjei Jensen
1999-11-26  0:00       ` Vladimir Olensky
1999-11-26  0:00         ` Robert Dewar
1999-11-26  0:00           ` Vladimir Olensky
1999-11-27  0:00             ` Robert Dewar
1999-11-28  0:00               ` Vladimir Olensky
1999-11-24  0:00 ` Tucker Taft
1999-11-24  0:00 ` Frank Klemm
1999-11-24  0:00   ` Lutz Donnerhacke
1999-11-29  0:00 ` Marin Condic
1999-11-29  0:00   ` Lutz Donnerhacke
1999-11-29  0:00     ` Marin Condic
1999-11-29  0:00       ` Lutz Donnerhacke
1999-11-29  0:00   ` Mike Silva
1999-11-29  0:00     ` Marin Condic
1999-11-29  0:00       ` Mike Silva
1999-11-29  0:00       ` John Duncan
1999-11-30  0:00         ` Lutz Donnerhacke
1999-11-30  0:00       ` Tarjei Jensen
1999-11-29  0:00   ` Robert C. Leif, Ph.D.
1999-12-01  0:00   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox