>>>>> "BW" == Brian Wheeler <[EMAIL PROTECTED]> writes:

  BW> On Fri, 2001-09-14 at 10:20, Dan Sugalski wrote:
  >> Okay, we've had a number of people in favor of a good macro assembler for 
  >> Parrot. Given that, do we have anyone who'll volunteer to define, maintain, 
  >> and extend the thing? (Presuming we jump off of the current assembler, 
  >> which seems reasonable)
  >> 
  >> There probably isn't a huge amount to do with the thing--maintain macro 
  >> substitutions, handle local labels, manage sub definitions, and suchlike 
  >> things.
  >> 

  BW> Wouldn't it largely be just filtering the input through cpp?

not in the least. :)

a proper macro assembler has many features that cpp can't even come
close too. even m4 doesn't do things that a classic macro assembler can
do. in pdp-11 assembler you could actually write a program in the
assembler itself! it was a mini-language with hooks to deal with stuff
like generating local private labels for loops, handling optional args
in macro expansions, iterating over lists of characters or tokens, etc.

here is an example (from very old brain cells):

<in pdp11 you used radix50 text which was upper case only :) >

.MACRO SAVE $ARG1 $ARG2?                ; ? is optional arg
.IFN $ARG2                              ; negative test (like unless)
        $ARG2 = STACK                   ; macro assignment
.END
; this code is emitted
        INC $ARG2                       ; bump the stack pointer
        MOV @$ARG2, $ARG1               ; push onto the stack
.ENDM

SAVE    BAR                             
SAVE    FOO, FOO_STACK

note that the condtional executes at expansion time, not macro
definition time. so that macro allows you to do a simple save and
set a stack default.

by using loops and conditionals and such, you can create macros that
work like inline subs (i did that with a major pdp-11 assembler project,
much of the common code was macros which did sub like work).

someone asked about named registers. well a macro assembler can do that
for you. you just map a register to a name and use it.

.DEF    I1, BASE
        INC BASE

the syntax of macro assemblers is usually fairly easy and line
oriented. no need for lookahead or recursive parsing. since assemblers
are line oreinted you canonly expand macros in the right place. there is
no need for cpp/m4 parsing of the text, a simple look for this here and
replace it by that is what is needed.

note that macros can call macros which does mean recursive expansion. i
don't believe a macro could define a macro though. IBM's massive BAL
macro assembler had something like 14 passes to compile it.

so, first we should define the features we want. obviously macros with
params and optional args is needed. support for basic expressions, 
conditionals and loops are a must. what kind of loops is a question?
with expressions and conditionals you can create any loop. do we want
loop directives to make it easier?

how tightly integrated with the assembler will this be? will it be a
separate pass/program or built in?

lots of questions. if someone teks this on, i will be interested in
helping with the design and possibly some coding. like i said, my coding
time is precious right now and i don't have many spare tuits. i do have
to earn a living. :)

uri

-- 
Uri Guttman  ---------  [EMAIL PROTECTED]  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org

Reply via email to