Request for assistance on a new BETA version of MASM32.

Started by hutch--, October 04, 2011, 01:24:28 PM

Previous topic - Next topic

hutch--

I have spent the last couple of weeks writing a new installation for the next version of MASM32, testing it and making sure it installs OK, added all the newer tools, rationalised the examples while adding new ones and have added a completely new set of include files that have direct UNICODE support. With special thanks to Ramon Sala who matched the WINDOWS.INC to the new include files, the main WINDOWS.INC and the rest of the include files respond to defining "__UNICODE__" and will use the UNICODE versions of API calls instead of the default ANSI API functions. Now I have it reasonably well tested on ANSI code but have done very little testing on UNICODE functions.

What I need is the assistance of some of our more experienced members in testing the installation and checking if it all works on other peoples computer configurations. It installs correctly on Win2000, WinXP SP3 and Win7 64 bit but noting that these test machines are configured properly for development and are not obstructed by either OS settings or AV scanners.

I have yet to do any real work on the libraries and documentation and this also must be done but what I need at the moment is a number of experienced people who can help with the testing of this new version. If you have the time would you let me know and I will send you the link to the BETA version. i have not directly posted the link as I don't want to have to wade through a pile of noise, nonsense and garbage, I actually need some assistance from people who know what they are doing.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ToutEnMasm

Ok to test it on:
                Intel(R) Celeron(R) CPU 2.80GHz
Microsoft Windows XP Professional Build Service Pack 3 2600
send me the link.
give it by personal message of the forum


ToutEnMasm


qWord

hi Hutch,

Have you update the unicode macros (bug)? Also there was a bug in the cmd$ macros.
Just seeing that you have introduce the __UNICODE__ equate, you may want also change the string support of the fn,rv,... macros -> means, that they produce a unicode strings if __UNICODE__  is defined?
Alternatively it may be useful to have the the 'L' prefix (like in c/c++) for strings - I've allready written my own fn/rv macros with these feature.

qWord

EDIT:
In the attachment the extended fn and rv macros. The syntax is:
unicode:
fn function,...,L'xyz',...,L"'quoted'"
ascii:
fn function,...,"xyz",...,'"double quoted"'
The same applies for rv(). Additional there are some high level features:
Insted of ADDR/OFFSET you can shortly prepend a '&' (as in c/c++):
fn function,&sz[0],...
Also for both, fn and rv, a optional destination can be placed in front of the function name:
fn dest32 = function,...
.if rv(dest2=myFunction,...)

These two features can of course be removed - they may be a bit to 'high' for some people  :bg
FPU in a trice: SmplMath
It's that simple!

hutch--

Yves,

Thanks, your help is much appreciated.

qWord,

I have not yet done any real work on the libraries or the macros but I a wary of changing any of the stuff that has been around for a long time as it may break existing code that people have already written. I don't fully understand the macros you have written but they look interesting and if they can be made general purpose enough I don't see any reason not to name them slightly differently and include them as well. What I do need with macros is some documentation so I know what they do and so that programmers can predictably use them.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

qWord

Quote from: hutch-- on October 05, 2011, 11:27:27 AMI don't fully understand the macros you have written but they look interesting and if they can be made general purpose enough I don't see any reason not to name them slightly differently and include them as well. What I do need with macros is some documentation so I know what they do and so that programmers can predictably use them.
ok, I will work on these macros and their documentation the next days.
FPU in a trice: SmplMath
It's that simple!

qWord

hi,
here are the macros. Just to make clear my naming convention for equates and textmacros: to make them unique I allways use the macros name, or an abbreviation of it, as a prefix.
AFAICS, they are full compatible with the current fn and rv macros, thus they should not break with existing code...

;/********************************************************************/
;/*                     fn - macro procedure                         */
;/* This macro enhanced the INVOKE-directive:                        */
;/*   - It adds support for quoted ASCII or unicode strings.         */
;/*     The strings can be either enclosed by double quotes or by    */
;/*     single quotation marks. Unicode strings are declared by      */
;/*     using the 'L'-prefix:                                        */
;/*         ASCII:     "my string" or  'my string'                   */
;/*         Unicode:  L"my string" or L'my string'                   */
;/*     MASM's reserved characters like exclamation marks, angel     */
;/*     brackets and single brackets [,...] can not be used.         */
;/*   - ADDR-expressions can be shorten by using a ampersand '&':    */
;/*         fn MessageBoxW,0,&wsz[0],L'xyz',0                        */
;/*   - a optional destination can be specified in front of the      */
;/*     function:                                                    */
;/*         fn dest=FncName,...                                      */
;/*                                                                  */
;/* Example:                                                         */
;/*     fn MessageBox,0,"my string",&wsz[0],0                        */
;/*     fn hWnd = CreateWindowEx,...                                 */
;/*                                                     qWord, 2011  */
;/********************************************************************/
fn macro FncName:req,args:VARARG

    ;/* check if a optional destination is specified */
    fnex_flag = 0
    IF @InStr(1,<&FncName>,<=>)
        fnex_flag = 1
        fnex_dest SUBSTR <&FncName>,1,@InStr(1,<&FncName>,<=>)-1
        fnex_arg TEXTEQU <invoke >,@SubStr(<&FncName>,@InStr(1,<&FncName>,<=>)+1)
    ELSE   
        fnex_arg TEXTEQU <invoke FncName>
    ENDIF

    ;/* process argument list and append it to the invoke-call */
    fnex_arg CATSTR fnex_arg,repargs(&args)

    ;/* place the function call */
    fnex_arg

    ;/* if available, fill the specified destination */   
    IF fnex_flag EQ 1
        mov fnex_dest,eax
    ENDIF
endm

;/********************************************************************/
;/*                     rv - macro function                          */
;/* This macro is the function-version of the fn-macro.              */
;/*                                                                  */
;/* Example:                                                         */
;/*      mov edi,rv(myFunction,L"my string",&wsz[0],...)             */
;/*      .break .if !rv(dest=myFunction,...)                         */
;/*                                                     qWord, 2011  */
;/********************************************************************/
rv macro FncName:req,args:VARARG
   
    ;/* check if a optional destination is specified */
    rvex_flag = 0
    IF @InStr(1,<&FncName>,<=>)
        rvex_flag = 1
        rvex_dest SUBSTR <&FncName>,1,@InStr(1,<&FncName>,<=>)-1
        rvex_arg TEXTEQU <invoke >,@SubStr(<&FncName>,@InStr(1,<&FncName>,<=>)+1)
    ELSE   
        rvex_arg TEXTEQU <invoke FncName>
    ENDIF

    ;/* process argument list and append it to the invoke-call */
    rvex_arg CATSTR rvex_arg,repargs(&args)
   
    ;/* place the function call */
    rvex_arg
   
    ;/* if available, fill the specified destination */
    IF rvex_flag EQ 1
        mov rvex_dest,eax
    ENDIF
    EXITM <eax>
endm

;/*******************************************************************/
;/*                     simplwsz , macro procedure                  */
;/* Creates a zero terminated Unicode string in current segment.    */                         
;/* Parameters:                                                     */
;/*     lbl : The label/name of the string                          */
;/*     txt : string, either enclosed by single quotation marks     */
;/*           or by double quotes. You cannot use MASM's            */
;/*           reserved characters like exclamation marks,           */
;/*           angel brackets, single brackets,... .                 */
;/*           <""> or <''> cause the cration of an empty string.    */
;/* Return: an error is indicated by setting the equate             */
;/*         smplwsz_error to 1                                      */
;/* Example:                                                        */
;/*     .data                                                       */
;/*         simplwsz myLabel,"unicode 123'4"                        */
;/*         IF smplwsz_error                                        */
;/*            ;; error                                             */
;/*         ELSE                                                    */
;/*            ;; OK, no error                                      */
;/*         ENDIF                                                   */
;/*     .code                                          qWord, 2011  */
;/*******************************************************************/
simplwsz macro lbl:req,txt:req

    smplwsz_error = 0

    ;/* remove leading blanks (trim) */
    FOR arg,<&txt>
        simplwsz_arg TEXTEQU <&arg>
        EXITM
    ENDM
   
    ;/* exit if argument is blank */
    IFB simplwsz_arg
        smplwsz_error = 1
        EXITM
    ENDIF
   
    simplwsz_pos1 INSTR 1,simplwsz_arg,<">
    simplwsz_pos2 INSTR 1,simplwsz_arg,<'>

    align 2
    lbl LABEL WORD

    ;/* check wether the string is enclosed by     */
    ;/* double quotes or by single quotation marks */
    IF simplwsz_pos1 EQ 1
        ;/* loop through all cahr. after removing the enclosing */
        ;/* double quotes                                       */
    %   FORC char,<@SubStr(%simplwsz_arg,2,@SizeStr(%simplwsz_arg)-2)>
            dw "&char"
        ENDM
    ELSEIF simplwsz_pos2 EQ 1                           */
    %   FORC char,<@SubStr(%simplwsz_arg,2,@SizeStr(%simplwsz_arg)-2)>
            dw '&char'
        ENDM
    ELSE
        ;/* invalid argument *
        smplwsz_error = 1
    ENDIF
    ;/* term. zero */
    dw 0
    EXITM
endm

;/*****************************************************************/
;/*                 repargs , macro function                      */
;/* Parse the arguments list 'args' and replace:                  */
;/*     - String literals by the corresponding OFFSET-expression  */
;/*       after creating an anonym string in the .data-section    */
;/*     - leading ampersands (&) by the ADDR operator             */
;/* All other arguments are left untouched.                       */
;/*                                                               */
;/* Details:                                                      */
;/*     This macro allows using ASCII and Unicode strings.        */
;/*     Unicode strings are defined by using the 'L'-Prefix:      */
;/*       L"my unicode string"  or L'my "quoted" string'          */
;/*     Furthermore, ampersands are replaced by <ADDR >, if they  */
;/*     are the first character of the argument:                  */
;/*        ..., &sz[0],...    ->   ..., ADDR sz[0],...            */
;/*                                                               */
;/* Return:                                                       */
;/*     The processed argument list. If a nonempty list is passed */
;/*     to the macro, the returned list is always leaded          */
;/*     by a comma:                                               */
;/*         <arg1,arg2,...> -> <,newArg1,newArg2,...>             */
;/*     The number of arguments in list is stored in              */
;/*     the equate repargs_cntr.                                  */
;/*                                                               */
;/* Remarks:                                                      */
;/*     This macro is designed to process arguments lists for     */
;/*     the INVOKE-directive.                                     */
;/*     The macro assumes to be called from the .code-section     */
;/*                                                               */
;/* Example:                                                      */
;/*     invk_txt TEXTEQU <invoke FncName>                         */
;/*     invk_txt CATSTR invk_txt,repargs(ArgumentList)            */
;/*     invk_txt                                                  */
;/*                                                  qWord, 2011  */
;/*****************************************************************/
repargs macro args:VARARG
   
    ;/* initialize global counter, which */
    ;/* is used for label-creation.      */
    IFNDEF repargs_glb_cntr
        repargs_glb_cntr = 0
    ENDIF

    repargs_cntr = 0
    repargs_args TEXTEQU <>
    FOR arg,<&args>
        repargs_txt  TEXTEQU <&arg>
       
        ;/* analyze current argument */
        repargs_pos1 INSTR 1,<&arg>,<">
        repargs_pos2 INSTR 1,<&arg>,<'>
        repargs_pos3 INSTR 1,<&arg>,<L">
        repargs_pos4 INSTR 1,<&arg>,<L'>
        repargs_pos5 INSTR 1,<&arg>,<!&>

        IF repargs_pos1 EQ 1 OR repargs_pos2 EQ 1
            ;/* create ASCII string */
            .data
                IF @SizeStr(<%repargs_txt>) GT 2
                    @CatStr(<$$_szlbl_>,%repargs_glb_cntr) db repargs_txt,0
                ELSE
                    @CatStr(<$$_szlbl_>,%repargs_glb_cntr) db 0
                ENDIF
            .code
            repargs_args TEXTEQU repargs_args,<,OFFSET $$_szlbl_>,%repargs_glb_cntr
            repargs_glb_cntr = repargs_glb_cntr + 1
        ELSEIF repargs_pos3 EQ 1 OR repargs_pos4 EQ 1
            ;/* remove 'L'-prefix  */
            repargs_txt SUBSTR repargs_txt,2
           
            ;/* create Unicode string */
            .data
                IF @SizeStr(<%repargs_txt>) GT 2
                    simplwsz @CatStr(<$$_wszlbl_>,%repargs_glb_cntr),<%repargs_txt>
                ELSE
                    @CatStr(<$$_wszlbl_>,%repargs_glb_cntr) dw 0
                ENDIF
            .code
            repargs_args TEXTEQU repargs_args,<,OFFSET $$_wszlbl_>,%repargs_glb_cntr
            repargs_glb_cntr = repargs_glb_cntr + 1
        ELSEIF repargs_pos5 EQ 1
            ;/* replace '&' with <ADDR > and append argument to list */
            repargs_args TEXTEQU repargs_args,<,>,<ADDR >,@SubStr(%repargs_txt,2,)
        ELSE
            ;/* record unprocessed argument */
            repargs_args TEXTEQU repargs_args,<,>,repargs_txt
        ENDIF
        repargs_cntr = repargs_cntr + 1
    ENDM
    EXITM repargs_args
endm



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

hutch--

qWord,

These look very useful but I am inclined to see them as extended capacity and would prefer them to be slightly renamed so that the originals are still available. The suggestion is to use "rvx" for extended capacity and "fnx" for the function version.

Now i have a question, would it be possible to modify the macros so they responded to the the UNICODE equate,


    __UNICODE__ equ 1   ; enable UNICODE API functions


I think this would be more useful than prefixing the quoted string with L"quoted text" and it would mean that the same code could be built in both ANSI and UNICODE formats.

I like the leading "&" notation option and imagine that many people will be pleased with the convenience of having it available.

The logic in the new include files switches the API calls based on the equate __UNICODE__ and looks basically like this.


AppendMenuA PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
IFNDEF __UNICODE__
  AppendMenu equ <AppendMenuA>
ENDIF

AppendMenuW PROTO STDCALL :DWORD,:DWORD,:DWORD,:DWORD
IFDEF __UNICODE__
  AppendMenu equ <AppendMenuW>
ENDIF


What the request was aimed at was using this logic to switch between ANSI and UNICODE string output simply by defining the equate.




Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

qWord

Quote from: hutch-- on October 06, 2011, 06:52:16 PMNow i have a question, would it be possible to modify the macros so they responded to the the UNICODE equate,
yes, it possible to create Unicode if the equate is defined( or its value is non-zero?). However, I would suggest to keep also the L-prefix, such it is possible to force unicode strings. This would be useful for situations, where mainly ASCII is used, but a few functions need unicode strings (e.g.: if you work with GDI+).

What do think about some new macros for creating Unicode strings?:
The current available macros, WSTR ans uni$, are very limited in their function. For example you can only create zero terminated strings, thus it is not possible to create strings over more than one line. Also they are limit to 118 char. and they can not be used with the SIZEOF and LENGTHOF operator.
I'm using macros , which allows declaration of strings (and C-Strings) with the same syntax as the DB-directive. This macros could be easily ported to masm32.
FPU in a trice: SmplMath
It's that simple!

qWord

hi,
I've adapted the macros, so that they work with __UNICODE__ equate:
If the equate is defined and has a nonzero value, unicode strings are created. Otherwise ASCII strings are created. The L-prefix is still available, thus you can force Unicode string creation.
I've also renamed the rv/fn-macros and added 4 new macros for string creation:
UCSTR and uc$()  -> allows declaration like MASM's DB-directive.
UCCSTR and ucc$() -> the same as UCSTR/uc$, but adds support for escape sequences

Can you send me a copy of the new package, so that I can make some test?

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

qWord

hi hutch--,
In the attachment the file with working macros (AFAICS) and two examples:

UCSTR / uc$()  -> unicode string , dependencies: none
UCCSTR / ucc$() -> unicode string + escape sequences, dependencies: none
UC TEXTEQU <UCSTR>
UCC TEXTEQU <UCCSTR>
The macros uc$ and ucc$ are creating zero terminated strings. The returned labels (all macros) can be used with the SIZEOF and LENGTHOF operator.

fnx / rvx() -> function call, dependencies: smplwsz, repargs(), UC_PREFIX
smplwsz -> unicode string, single argument, dependencies: none

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

hutch--

Thanks, I will set them up for testing and come back to you.  :U
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

XP Mce2005 Sp3
Hello World
This is a MASM32's uicode support test.
next line
"quoted text"
This is a C-String!
()<>\
        This Text
        needs
        four
        lines
!!!


major bug !!!! - the "n" is missing in "unicode"   :bg



i suppose i need to have some foreign character set installed ?

qWord

Quote from: dedndave on October 10, 2011, 04:30:40 AM
i suppose i need to have some foreign character set installed ?
yes :-)
FPU in a trice: SmplMath
It's that simple!

hutch--

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php