The MASM Forum

Projects => MASM32 => Topic started by: dedndave on April 16, 2013, 03:18:04 PM

Title: ustr$ Problem ?
Post by: dedndave on April 16, 2013, 03:18:04 PM
mov eax,-216152991
print ustr$(eax),13,10
inkey
exit


result.....
-216152991

i thought ustr$ displayed unsigned dwords

      ustr$ MACRO number
        LOCAL buffer
        .data?
          buffer TCHAR 40 dup (?)
          align 4
        .code
        IFNDEF __UNICODE__
          invoke crt__itoa,number,ADDR buffer,10
        ELSE
          invoke crt__itow,number,ADDR buffer,10
        ENDIF
        EXITM <eax>
      ENDM


oops
i think crt__ultoa/crt__ultow was what you wanted

can't believe i am just now finding this - lol
Title: Re: ustr$ Problem ?
Post by: Magnum on April 16, 2013, 10:38:59 PM
Dave,

I did not see a question.

Are you talking to yourself  ? :biggrin:

Andy
Title: Re: ustr$ Problem ?
Post by: dedndave on April 16, 2013, 11:19:42 PM
oops
i think crt__ultoa/crt__ultow was what you wanted


reporting an error
Hutch doesn't like it when we ask questions in this sub-forum - lol
Title: Re: ustr$ Problem ?
Post by: hutch-- on April 17, 2013, 12:40:51 AM
I have read it but have not had time to look at the problem.
Title: Re: ustr$ Problem ?
Post by: dedndave on April 17, 2013, 01:23:15 AM
i am guessing it was a simple copy/paste mistake   :P
Title: Re: ustr$ Problem ?
Post by: dedndave on May 13, 2013, 12:23:06 AM
(http://www.en.kolobok.us/smiles/artists/mini/connie_mini_bump.gif)
Title: Re: ustr$ Problem ?
Post by: jj2007 on May 13, 2013, 01:09:11 AM
(http://www.masmforum.com/board/index.php?action=dlattach;id=3712;type=avatar)
Title: Re: ustr$ Problem ?
Post by: Gunther on May 13, 2013, 01:21:05 AM
Jochen,

what has lingo's old avatar to do with Dave?

Gunther
Title: Re: ustr$ Problem ?
Post by: dedndave on May 13, 2013, 01:32:58 AM
 :biggrin:

i try to maintain my masm32 library so it's compatible with other members
but, i may go off the grid with str$, ustr$, and uhex$
probably the stuff i use most out of m32lib

i would also like to upgrade them so they are unicode aware
i don't control the library, but i do have control of it on my disk   :biggrin:
Title: Re: ustr$ Problem ?
Post by: qWord on May 13, 2013, 02:02:32 AM
yep, beside some bugs, there are some macros that are currently not TCHAR aware. Also I'm missing some important macros in this context. e.g. for declaring TCHAR data in arbitrary segment.

For hutch it might be more helpful if we supply him such an file with some comments what has been added and corrected...
Title: Re: ustr$ Problem ?
Post by: jj2007 on May 13, 2013, 03:42:35 AM
Quote from: Gunther on May 13, 2013, 01:21:05 AM
what has lingo's old avatar to do with Dave?

Nothing. Just a warning to the little bird in the glass 8)
Title: Re: ustr$ Problem ?
Post by: Gunther on May 13, 2013, 03:57:42 AM
Quote from: jj2007 on May 13, 2013, 03:42:35 AM
Nothing. Just a warning to the little bird in the glass 8)

Ah, I understand. Thank you for the advice.  ;)

Gunther
Title: Re: ustr$ Problem ?
Post by: dedndave on May 13, 2013, 05:35:59 AM
something else that is handy is, sometimes, i want to load the address into a register
        mov        edx,uhex$(eax)

it works for uhex$ because the macro is written to exit with the address
      uhex$ MACRO DDvalue   ;; unsigned DWORD to hex string
;
;
;
        EXITM <OFFSET rvstring>
      ENDM


but, it doesn't work for ustr$ or sstr$
      ustr$ MACRO number
;
;
;
        EXITM <eax>
      ENDM
Title: Re: ustr$ Problem ?
Post by: qWord on May 13, 2013, 05:57:53 AM
Quote from: dedndave on May 13, 2013, 05:35:59 AMbut, it doesn't work for ustr$ or sstr$
why does it not work? EAX holds the address.
Title: Re: ustr$ Problem ?
Post by: jj2007 on May 13, 2013, 05:58:28 AM
Quote from: dedndave on May 13, 2013, 05:35:59 AM
but, it doesn't work for ustr$ or sstr$
...
        EXITM <eax>

Works fine, Dave. What doesn't work is
      mov eax, str$(123)
because of
      EXITM <ADDR rvstring>

I recommend
      mov esi, Str$ (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1186)("This is %i times more powerful", 100)
;)
Title: Re: ustr$ Problem ?
Post by: dedndave on May 13, 2013, 09:45:59 AM
of course, it works now - lol
i remember wanting to do something along that line a while back and failing   :redface:
it may have been the old version - or i may have been trying to do something else
Title: Re: ustr$ Problem ?
Post by: dedndave on May 15, 2014, 01:44:52 AM
(http://www.dinasaurhedcult.com/forums/images/smilies/bump.gif)

        mov     eax,80000000h
        print   ustr$(eax)


result
-214783648

ustr$ is Unsigned, right ?
Title: Re: ustr$ Problem ?
Post by: dedndave on May 15, 2014, 01:47:19 AM
masm32_v10 macro
      ustr$ MACRO DDvalue   ;; unsigned integer from string
        LOCAL rvstring
        .data
          rvstring db 20 dup (0)
        align 4
        .code
        ;; invoke dwtoa,DDvalue,ADDR rvstring
        invoke crt__ultoa,DDvalue,ADDR rvstring,10
        EXITM <OFFSET rvstring>
      ENDM


current macro
      ustr$ MACRO number
        LOCAL buffer
        .data?
          buffer TCHAR 40 dup (?)
          align 4
        .code
        IFNDEF __UNICODE__
          invoke crt__itoa,number,ADDR buffer,10
        ELSE
          invoke crt__itow,number,ADDR buffer,10
        ENDIF
        EXITM <eax>
      ENDM
Title: Re: ustr$ Problem ?
Post by: dedndave on May 15, 2014, 02:08:59 AM
this seems to work ok, unless someone sees a problem ?

      ustr$ MACRO number
        LOCAL buffer
        .data?
          buffer TCHAR 40 dup (?)
          align 4
        .code
        IFNDEF __UNICODE__
          invoke crt__ultoa,number,ADDR buffer,10
        ELSE
          invoke crt__ultow,number,ADDR buffer,10
        ENDIF
        EXITM <eax>
      ENDM


tested with both ANSI and UNICODE builds