News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

ustr$ Problem ?

Started by dedndave, April 16, 2013, 03:18:04 PM

Previous topic - Next topic

dedndave

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

dedndave



        mov     eax,80000000h
        print   ustr$(eax)


result
-214783648

ustr$ is Unsigned, right ?

dedndave

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

dedndave

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