[A83] Re: Macros


[Prev][Next][Index][Thread]

[A83] Re: Macros




At 08:34 PM 7/7/01 EDT, you wrote:
>
>Hey all - I am trying to write a different version of asm and I noticed 
>somewhere on this list that certain types of macros could be used such as
like
> 
>Line(xxxx,yyyy,aaaa,bbbbb) = ld de,xxxx*256+yyyy \ ld hl,aaaa*256+bbbb \ 
>bcall(_iline)
>
>how do i do those type of things if they are possible?

Is you mean in TASM, you have it right there.  You put a backslash to
denote character returns, and you use letters to denote parameters.  You
can then write it out like the parameters were actual values.

If you mean writeing it into your own assembler, you need to write a
parser.  In QB, it looks like this, kinda.  Mine is optimized for
interpretting ZZT statements, so you'll have to tweak it.  The QB ompiler
diesn't do arrays in types (structs, basically) I had to do param1, param2,
etc.  If you use a better compiler, you can just have parameters go out in
an array.

OPEN (filename$) FOR INPUT AS #1
DO UNTIL EOF(1)
        INPUT #1, line$
        a = INSTR(line$, " ")
        IF a = 0 THEN a = LEN(line$): code(i).nump = 0
        code(i).comm = LEFT$(line$, a)
        line$ = RIGHT$(line$, LEN(line$) - a)
        a = INSTR(line$, " ")
        IF a = 0 THEN a = LEN(line$): code(i).nump = 1
        code(i).param1 = LEFT$(line$, a)
        line$ = RIGHT$(line$, LEN(line$) - a)
        a = INSTR(line$, " ")
        IF a = 0 THEN a = LEN(line$): code(i).nump = 2
        code(i).param2 = LEFT$(line$, a)
        line$ = RIGHT$(line$, LEN(line$) - a)
        a = INSTR(line$, " ")
        IF a = 0 THEN a = LEN(line$): code(i).nump = 3
        code(i).param3 = LEFT$(line$, a)
        line$ = RIGHT$(line$, LEN(line$) - a)
        a = INSTR(line$, " ")
        IF a = 0 THEN a = LEN(line$): code(i).nump = 4
        code(i).param4 = LEFT$(line$, a)
        PRINT code(i).comm; ","; code(i).param1; ","; code(i).param2; ",";
code(i).param3; ","; code(i).param4
        i = i + 1
LOOP




References: