News:

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

surprising macro problem

Started by ToutEnMasm, February 12, 2009, 08:35:00 AM

Previous topic - Next topic

ToutEnMasm


I use often this macro that return the adress of the chain
Quote
      CREDATA MACRO quoted_text:REQ,NomdeChaine
         LOCAL Local_Etiquette,verif
      IFNB <NomdeChaine>         ;present
         verif SUBSTR <NomdeChaine>,1,1
            IFIDN verif,<">            ;first char is "
               .ERR  <ETIQUETTE SUPRIMER les " >         
            ENDIF
         Local_Etiquette TEXTEQU <NomdeChaine>   
      ENDIF
      verif SUBSTR <quoted_text>,1,1            
      IFDIF verif,<">
         .ERR  <CHAINE AJOUTER LES " >
      ENDIF
   
      .data
      Local_Etiquette db quoted_text,0
      .code
      EXITM <Local_Etiquette>
      ENDM
    ; ----------------------------------------------------
    ; return adress of the created chain, SADR("chaine")
    ; -----------------------------------------------------
         SADR MACRO quoted_text:REQ,NomdeChaine
           EXITM <ADDR CREDATA(quoted_text,NomdeChaine)>
         ENDM

Works well until i use it like that , SADR("!DefaultKeywordIndex")
The "!" disappear from the chain in data ???????????

The following macro don't made this.

Quote
    reparg MACRO arg
      LOCAL nustr
        quot SUBSTR <arg>,1,1
      IFIDN quot,<">            ;; if 1st char = "
        .data
          nustr db arg,0        ;; write arg to .DATA section
        .code
        EXITM <ADDR nustr>      ;; append name to ADDR operator
      ELSE
        EXITM <arg>             ;; else return arg
      ENDIF

Perhaps someone have an answer ?












japheth


> Perhaps someone have an answer ?

I not only have an answer but also a suggestion how to implement a workaround.

The problem is if a literal contains '!' and is used in angle brackets (i.e. as a macro parameter), the '!' becomes an operator (MS calls it the "literal character" operator).

In you sample, you can avoid '!' becoming an operator if you change your SADR macro a bit:


         SADR MACRO quoted_text:REQ,NomdeChaine
           EXITM @CatStr(<ADDR >, CREDATA(quoted_text,NomdeChaine))
         ENDM



ToutEnMasm