Author Topic: ustr$ Problem ?  (Read 10052 times)

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: ustr$ Problem ?
« Reply #15 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

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: ustr$ Problem ?
« Reply #16 on: May 15, 2014, 01:44:52 AM »


Code: [Select]
        mov     eax,80000000h
        print   ustr$(eax)

result
Code: [Select]
-214783648
ustr$ is Unsigned, right ?

dedndave

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: ustr$ Problem ?
« Reply #17 on: May 15, 2014, 01:47:19 AM »
masm32_v10 macro
Code: [Select]
      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
Code: [Select]
      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

  • Member
  • *****
  • Posts: 8827
  • Still using Abacus 2.0
    • DednDave
Re: ustr$ Problem ?
« Reply #18 on: May 15, 2014, 02:08:59 AM »
this seems to work ok, unless someone sees a problem ?

Code: [Select]
      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