Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!husc6!cmcl2!brl-adm!adm!chris@mimsy.umd.EDU From: chris@mimsy.umd.EDU (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: Teaching Assembler on VAX (BSD 4.3) Message-ID: <7447@brl-adm.ARPA> Date: Tue, 19-May-87 10:31:05 EDT Article-I.D.: brl-adm.7447 Posted: Tue May 19 10:31:05 1987 Date-Received: Wed, 20-May-87 04:48:27 EDT Sender: news@brl-adm.ARPA Lines: 75 From: Root Boy Jim I don't have the original article, but maybe he meant "is it" [it being m4, the question being is it tailored to C] rather then "it is". I don't see m4 as being particularly tailored for or against C or assembly or anything else for that matter. m4 is just about maximally untailored. What makes an assembler friendly or unfriendly? I'm surprised you had to ask, Chris, or was that a rhetorical question? No: I have never had much use for fancy macros in assembly. All I want from an assembler is that it assemble, quickly, and that it tell me where something is wrong. There is so little to go wrong that it does not matter *what*: just *where*. I think [an extensive macro facility] is a major requirement for serious asm hacking. As a litmus test, I would say the ability to write a set of macros which implemented if-then-else, while, and the like (in short, a mini compiler), is a pretty good assembler. I had never even considered using macros for higher level constructs. When I wanted higher level contstructs, I used higher level languages. (I thought that was what they were for...? :-) ) In fact, I would rather use cpp for assembly as well. But perhaps m4 can generate multi-line text? It does indeed. Here is something that friend of mine whipped up yesterday while playing with m4: define(for,`define'($1,$2)`ifelse($2,$3,$4 ,$4 undefine(`$1')`for'($1,`incr'($2),$3,$4))') for(i,1,6,xxx(i) + i) define(pushall,`ifelse($1,,,push $1 `pushall'($2,$3,$4,$5,$6,$7,$8,$9))')dnl pushall(a,b,c) define(popall, `ifelse($1,,,`popall'($2,$3,$4,$5,$6,$7,$8,$9)pop $1 )')dnl popall(a,b,c) Run on this, m4 produces the following (adjacent blank lines squished out): xxx(1) + 1 xxx(2) + 2 xxx(3) + 3 xxx(4) + 4 xxx(5) + 5 xxx(6) + 6 push a push b push c pop c pop b pop a Not particularly useful for anything, perhaps, but it does demonstrate that m4 can do at least some of what those other macro facilities can do.