News:

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

Unicode in POASM

Started by hutch--, January 05, 2006, 12:40:59 AM

Previous topic - Next topic

hutch--

Here is a very simple example of unicode using POASM. Another rung in the ladder of becoming a giant killer.  :U

[attachment deleted by admin]
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

tenkey

Great!

Just like I thought it should be done.

Is there a way to deal with a potential clash with MASM usage?

dw "AB" ; MASM yields two bytes 42H followed by 41H
dw "AB" ; POASM yields two words 0041H followed by 0042H

Of course, if you start using the C style escapes, you've already left some MASM compatibility behind.
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

hutch--

I have just been playing with a couple of macros. The "uni" macro works fine as it is very simple, I have tried to get part of the masm macro "fn" going but run into a problem with CATSTR when trying to append text from the argument in the FOR loop.


comment * ----------------------------
        The "var" argument in the FOR
        loop will not append to "argz"
        using the CATSTR operator without
        <var> which simply appends "var"
        ---------------------------- *
        fn MACRO FuncName:REQ,args:VARARG
        LOCAL argz
          argz equ <invoke FuncName>
          FOR var,<args>
            argz CATSTR argz,<,>,<var>
            .echo var
            .echo argz
          ENDM
          .echo argz
        ENDM

comment * -------------
        This works fine
        ------------- *
        uni MACRO quoted_text
        LOCAL utxt
          .data
            utxt dw quoted_text,0
          .code
          EXITM <OFFSET utxt>
        ENDM

    .data
      tttl dw "Unicode in POASM",0
      tmsg dw "Its this easy,\n\ntxtname dw \"YourText\",0",0

   

    .code

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

start:

    fn TestFunction,0,"Test text",0,0

    invoke MessageBoxW,0,uni("Unicode String Macro"),uni("Unicode title"),MB_OK

    invoke MessageBoxW,0,ADDR tmsg,ADDR tttl,MB_OK
    invoke ExitProcess, 0
    ret

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

PellesC

Quote from: tenkey on January 05, 2006, 05:32:32 AM
Is there a way to deal with a potential clash with MASM usage?

dw "AB" ; MASM yields two bytes 42H followed by 41H
dw "AB" ; POASM yields two words 0041H followed by 0042H

Of course, if you start using the C style escapes, you've already left some MASM compatibility behind.
Anything is possible, I guess - to me it seems much more logical, and useful, that dw "..." always produces a Unicode string, rather than (for example) two bytes for dw "AB" and six bytes for dw "ABC"...

Pelle

PellesC

Quote from: hutch-- on January 05, 2006, 09:01:29 AM
I have just been playing with a couple of macros. The "uni" macro works fine as it is very simple, I have tried to get part of the masm macro "fn" going but run into a problem with CATSTR when trying to append text from the argument in the FOR loop.
I will look at it...

Pelle

zooba

Quote from: tenkey on January 05, 2006, 05:32:32 AM
Is there a way to deal with a potential clash with MASM usage?

dw "AB" ; MASM yields two bytes 42H followed by 41H
dw "AB" ; POASM yields two words 0041H followed by 0042H

Of course, if you start using the C style escapes, you've already left some MASM compatibility behind.

Bug Microsoft until they change it  :P
POASM is behaving like C here, MASM probably should as well.

Randall Hyde

Personally, I'd prefer to see a new pseudo op (like Hutch's UNI) and make dw adhere to the MASM syntax.  And while you're at it, another couple of pseudo-opcode extensions:

utf8
utf16

Both of which would essentially behave like db, except that operations like @size or @length (or whatever) would return a character count rather than a byte count.

Cheers,
Randy Hyde

hutch--

If a bit more grunt can be got out of the pre-processor, we should be able to get the best of all worlds here. I have done macros to try and emulate unicode that are effectively,

txt dw a,b,c,d,f,e,g,h,0 etc ...

But masm already does the EQU replacements before you can access the text passed to the macro and you occasionally get strange results.

If a bit more capacity turns up, the type of macros in masm32 like "fn" and "rv" can be emulated so that you can substitute text into any API call which is a lot more powerful that seperately inserting smaller macros. Especially so with the C escapes capacity thats already running.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

PellesC

Quote
dw "AB" ; MASM yields two bytes 42H followed by 41H
dw "AB" ; POASM yields two words 0041H followed by 0042H
I will issue a warning (for now) that this specific case is interpreted as Unicode. A single character happens to give the same result as MASM, and three characters or more will be rejected by MASM (so that's not an issue). Seems cleaner to use DW for Unicode strings, rather than inventing even more reserved words (which at least I don't need...)

Pelle

PBrennick

Pelle,
As for me, I see your interpretation as being very logical, I find it gratifying that you are doing things in a way that makes sense to you.  We already have a MASM, don't need another one.  With good suggestions from Hutch (and others) this really is shaping up to be a giant killer!

Paul
The GeneSys Project is available from:
The Repository or My crappy website

Mark Jones

Finally, an easy way to implement other languages! Yay!  どもありがとう! :toothy
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08