Author Topic: a text MACRO working in ANSI or UNICODE format  (Read 16004 times)

TouEnMasm

  • Member
  • *****
  • Posts: 1764
    • EditMasm
Re: a text MACRO working in ANSI or UNICODE format
« Reply #15 on: October 18, 2012, 04:28:02 AM »

The only one difference is here,on the label
Quote
Monlabel  WORD 6 dup (?)
        dw 0
        dw 1
        dw 2

Who allow to get the size and Lengthof
Fa is a musical note to play with CL

TouEnMasm

  • Member
  • *****
  • Posts: 1764
    • EditMasm
Re: a text MACRO working in ANSI or UNICODE format
« Reply #16 on: October 18, 2012, 06:45:36 AM »

added support for sizeof and lengthof,
Replaced the "X" by "/" ,same usage.

Quote
AU MACRO adresse:REQ,ARGS:VARARG
   local verif,count,decompte
   count = 0
   decompte = 1   ;made a loop without write nothing   
   IFDEF __UNICODE__
      :WriteWord
      verif equ <adresse>
      IFDIF verif,</>
         IF decompte EQ 0
            adresse WORD count dup (?)
            org $- count*2      ;return to adresse
            count = 0
         ENDIF
      ENDIF
            
      FOR _arg,<ARGS>
         verif SUBSTR <_arg>,1,1
         IFIDN verif,<">   
            FORC char,<_arg>   
               IFDIF <char>,<">
                  IF decompte EQ 0
                     cumul TEXTEQU <DW "&char">
                     cumul ;execute
                  ENDIF
                  count = count + 1
               ENDIF
            ENDM
         ELSE
            IF decompte EQ 0         
               DW _arg
            ENDIF
            count = count + 1                     
         ENDIF
      ENDM
      IF decompte EQ 1
          decompte = 0
          GOTO WriteWord
      ENDIF
      EXITM<>

   ELSE
      :WriteByte
      verif equ <adresse>
      IFDIF verif,</>
         IF decompte EQ 0
            adresse BYTE count dup (?)
            org $- count      ;return to adresse
            count = 0
         ENDIF
      ENDIF
            
      FOR _arg,<ARGS>
         verif SUBSTR <_arg>,1,1
         IFIDN verif,<">   
            FORC char,<_arg>   
               IFDIF <char>,<">
                  IF decompte EQ 0
                     cumul TEXTEQU <DB "&char">
                     cumul ;execute
                  ENDIF
                  count = count + 1
               ENDIF
            ENDM
         ELSE
            IF decompte EQ 0         
               DB _arg
            ENDIF
            count = count + 1                     
         ENDIF
      ENDM
      IF decompte EQ 1
          decompte = 0
          GOTO WriteByte
      ENDIF
      EXITM<>      
   ENDIF            
ENDM
NAU MACRO namelabel:REQ,ARGS:VARARG
   .data
   AU (namelabel,ARGS)
   .code
   EXITM <namelabel>
ENDM   


Fa is a musical note to play with CL

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: a text MACRO working in ANSI or UNICODE format
« Reply #17 on: October 18, 2012, 08:32:37 AM »
   adresse WORD count dup (?)
   org $- count*2      ;return to adresse

Nice trick, Yves :t