From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ef33c33c4f98bde1 X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: Compiler for Z80/6510 Date: 1999/12/02 Message-ID: <3846E271.EC40F07C@mitre.org>#1/1 X-Deja-AN: 555932872 Content-Transfer-Encoding: 7bit References: <3845D4B4.98354460@mitre.org> <1999Dec2.080628.1@eisner> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.mitre.org X-Trace: top.mitre.org 944169200 616 129.83.41.77 (2 Dec 1999 21:13:20 GMT) Organization: The MITRE Corporation Mime-Version: 1.0 NNTP-Posting-Date: 2 Dec 1999 21:13:20 GMT Newsgroups: comp.lang.ada Date: 1999-12-02T21:13:20+00:00 List-Id: 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...