piclist 1999\02\26\220000a >
Thread: MPASM macros
www.piclist.com/techref/language/index.htm?key=asm
flavicon
face BY : Mark Willis email (remove spam text)



Josef Hanzal wrote:
>
> I would like to have macro, which behaves differently when argument is
> defined and when it is not. The manual says, that argument which is omitted
> equals to an empty string, but I cannot find a way, how to test for string
> lenght. Has someone already solved this? I tried the following way, but it
> is not working, as there is no substitution for MENUITEM in the IFDEF
> statement when macro is invoked. I tried several more complicated ways, but
> no good results so far. Any suggestions? MPASM 2.15
>
> STRING  MACRO   STR,MENUITEM
> STR#V(STRNO):   DT STR,0
>  IFDEF  MENUTITEM
> MENUITEM:       EQU STRNO
>  ENDIF
>         ENDM
>
> Josef

 Your IFDEF MENUTITEM there has an "extra" T in the middle there, I'm
hoping that's not the cause of the problem?

 I've used "Test Equ NullArg   555" before on other platforms (I'm not
where I can test it here, but it worked in CDC Cyber mainframe assembly
and has worked other places <G> - but NullArg has to be numberical for
that to work.)  Sets a default of 555 (here), for an omitted argument.
I should test that on MPAsm, huh?

 #IFNDEF looks like a candidate here as well.  If it's falling through
on an undefined string, then
 #IFNDEF MENUITEM
;    NOTE Fell through
 #ELSE
MENUITEM:       EQU STRNO
 #ENDIF

 "Programming is the art of thinking deviously enough to figure out how
to get what you want, while not violating the principle of least
astonishment" <G>

 Have you used #EXPAND?  (or is it EXPAND?  I forget.)  To expand the
macro invocation and see more info on what's going through MPASM's head.

 Worst case, add a 3rd arg in the middle:
 STRING  MACRO   STR,BOOL,MENUITEM

 Set Bool=1 when you'll have a MENUITEM.  Icky though.  I'm no MPAsm
expert, and too rusty on Parallax's Assembler now.

 Mark

<36D75F27.5A5A9353@nwlink.com> 7bit

See also: www.piclist.com/techref/language/index.htm?key=asm
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) MPASM macros

month overview.

new search...