The MASM Forum Archive 2004 to 2012

Specialised Projects => Pelle's Macro Assembler Development => Topic started by: hutch-- on January 21, 2006, 02:13:37 AM

Title: Unicode macros
Post by: hutch-- on January 21, 2006, 02:13:37 AM
The native unicode support is very easy to use now that the pre-processor allows some more complex macros.



    repargu MACRO arg           ;; UNICODE version
      LOCAL nustr
      IF (OPATTR arg) AND 8000h ;; is it a "string"...?
        .data
          nustr dw arg,0        ;; write arg to .DATA section
        .code
        EXITM <ADDR nustr>      ;; append name to ADDR operator
      ELSE
        EXITM <arg>             ;; else return arg
      ENDIF
    ENDM

    ufn MACRO FuncName:REQ,args:VARARG
      arg equ <invoke FuncName>         ;; construct invoke and function name
      FOR var,<args>                    ;; loop through all arguments
        arg CATSTR arg,<,>,repargu(var) ;; replace quotes and append arg
      ENDM
      arg                               ;; write the invoke macro
    ENDM

    urv MACRO FuncName:REQ,args:VARARG
      arg equ <invoke FuncName>         ;; construct invoke and function name
      FOR var,<args>                    ;; loop through all arguments
        arg CATSTR arg,<,>,repargu(var) ;; replace quotes and append arg
      ENDM
      arg                               ;; write the invoke macro
      EXITM <eax>
    ENDM
-------------------

Just append the "W" at the end of the API name, change
the macro to "urv" and BINGO,Instant UNICODE support.

    mov retval, urv(MessageBoxW,hWnd,"Testing the RV macro","Title",MB_OK)
Title: Re: Unicode macros
Post by: Shantanu Gadgil on January 21, 2006, 07:48:53 AM
not to be picky...but is there any convention as to where the 'u' goes between the ASCII/UNICODE macro.
Point is case being "fn" becomes "ufn", but "reparg" becomes" "repargu".
Title: Re: Unicode macros
Post by: Shantanu Gadgil on January 21, 2006, 08:01:13 AM
just an idea...
instead of using only "u" could we use "uni" ?

I say that because a single "u" is easier to miss than "uni" !!!

There could be other ways too...PREPENDING "uni_" or APPENDING "_uni"

This is just an idea...I won't bug you about this any more :cheekygreen: totally upto you ! :)
Title: Re: Unicode macros
Post by: hutch-- on January 21, 2006, 09:28:37 AM
I am much more interested in readability that some arbitrary convention.

The other factor is to keep the macro name short. Things like this_is_a_unicode_macro_that_returns_a_dword_value don't improve readability but they sure increase the typing.
Title: Re: Unicode macros
Post by: Shantanu Gadgil on January 23, 2006, 06:01:22 PM
I agree !!!

>>...some arbitrary convention.
Yes I know...somebody starts spewing words like "convention", "standards", "guidelines", etc, I'd feel like slapping them too. :)

I know I'd said I will not bug you...I'm STILL NOT going to bug you...just a small point. :)

The thought was for new programmers, you know...patterns are easier to learn (like the ...Ex thing with the Win32 API)..., thats all. :)
Title: Re: Unicode macros
Post by: zooba on January 24, 2006, 01:53:21 AM
How about a pre-include UNICODE flag which selects which macro set and function equates (ie. GetWindowText EQU GetWindowTextA) to use?
Title: Re: Unicode macros
Post by: ToutEnMasm on August 13, 2011, 05:18:11 PM

I was happy reading this:
Quote
The native unicode support is very easy to use now that the pre-processor allows some more complex macros.
and try:
Quote
   ;chaine DW 'U','N','I',"C","O","D","E",0
   chaine DW "UNICODE",0
answer of ml    error A2084:constant value too large
only the form chaine DW 'U','N','I',"C","O","D","E",0 is accepted.

Is there another macro who do that ?





Title: Re: Unicode macros
Post by: qWord on August 13, 2011, 05:27:18 PM
/masm32/macros/ucmacros.asm
-> WSTR and uni$()
Title: Re: Unicode macros
Post by: ToutEnMasm on August 13, 2011, 05:42:43 PM

Thanks