News:

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

problem with dwtoa 64

Started by ecube, June 03, 2010, 09:23:47 AM

Previous topic - Next topic

ecube


dwtoa FRAME dwValue, lpBuffer
    USES rbx,rsi,rdi

    mov rax, [dwValue]
    mov rdi, [lpBuffer]

    test rax,rax
    jnz  > .sign

  .zero
    mov W[rdi],30h
    jmp >> dtaexit

  .sign
    jns > .pos
    mov B[rdi],'-'
    neg rax
    add rdi, 1

  .pos
    mov rcx, 3435973837
    mov rsi, rdi

    ;.while (rax > 0)
    :
      cmp rax,0
      jle >
      mov rbx,rax
      mul rcx
      shr rdx, 3
      mov rax,rdx
      lea rdx,[rdx*4+rdx]
      add rdx,rdx
      sub rbx,rdx
      add bl,'0'
      mov B[rdi],bl
      add rdi, 1
      jmp <
    ;.endw

:
    mov B[rdi], 0       ; terminate the string

    ; We now have all the digits, but in reverse order.

   ; .while (rsi < rdi)
    :
      cmp rsi,rdi
      jge > dtaexit
      sub rdi, 1
      mov al, B[rsi]
      mov ah, B[rdi]
      mov B[rdi], al
      mov B[rsi], ah
      add rsi, 1
    ;.endw
jmp <
  dtaexit:
    ret

ENDF


not returning the right value, for

invoke dwtoa,5000,addr mybuff

returns ','

any ideas?

wjr

So close with the conversion to 64-bit... a little tricky to spot, but the 3435973837 in hex is 0CCCCCCCDh which is still 32-bit so try 0CCCCCCCCCCCCCCCDh instead.

ecube

that fixed it, thanks wjr you're the man  :U