News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

macro parameter pparsing

Started by korte, August 24, 2009, 10:16:13 AM

Previous topic - Next topic

korte



Want macro

  set any <- xbit


low level code
or  any,xbit


how to parsing?




qWord

Quote from: korte on August 24, 2009, 10:16:13 AM
Want macro
-> I want a bottle of cold beer  :bg
---

you can't use angle brackets directly in a macro call (masm throws a warning if so) - if you want such an "syntax" you must use quotes: "eax <- xyz" or 'eax<-xyz'

here is an example-macro ... maybe it is what you want:
set macro txt:=< >
    s_txt TEXTEQU @CatStr(txt)
    s_size SIZESTR s_txt

    s_pos1 INSTR 1,s_txt,<!">
    s_pos2 INSTR 1,s_txt,<!<->
    IF s_pos1+1 LE s_size
        s_pos3 INSTR s_pos1+1,s_txt,<!">
    ELSE
        .err <syntax error>
        EXITM
    ENDIF
    IF (s_pos1 EQ 0) OR (s_pos2 EQ 0) OR (s_pos3 EQ 0)
        .err <syntax error>
        EXITM
    ENDIF

    s_arg1 SUBSTR s_txt,s_pos1+1,s_pos2-s_pos1-1
    s_arg2 SUBSTR s_txt,s_pos2+2,s_pos3-s_pos2-2
    IFB s_arg1
        .err <missing argument>
        EXITM
    ELSEIFB s_arg2
        .err <missing argument>
        EXITM
    ENDIF
    or s_arg1,s_arg2
endm
...
set "eax<-0100y"

FPU in a trice: SmplMath
It's that simple!