News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

a problem on masm32\m32lib\a2dw.asm win7

Started by Rainboy, February 01, 2014, 09:20:54 PM

Previous topic - Next topic

Rainboy

 :(
a2dw proc uses ecx edi edx esi String:DWORD

      ;----------------------------------------
      ; Convert decimal string into dword value
      ; return value in eax
      ;----------------------------------------

      xor ecx, ecx
      mov edi, String
      invoke lstrlen, String

when you call lstrlen,it will change ecx,so program will wrong,

such as


so change for right
    xor ecx, ecx
      mov edi, String
      invoke lstrlen, String
    xor ecx,ecx

I spend my whole afternoon on it,I feel sad  :( :( :( :(, I think my elder should be correct

hutch--

Yes thanks, we knew about this problem of a very old algorithm that had errors. This is its replacement. Here is the forum link to the change.

http://masm32.com/board/index.php?topic=1377.0


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    .686p                     ; maximum processor model
    .XMM                      ; SIMD extensions
    .model flat, stdcall      ; memory model & calling convention
    option casemap :none      ; case sensitive

  ; -----------------------------------------------------------------------
  ; This version is a drop in replacement for Iczelion's original algorithm
  ; -----------------------------------------------------------------------
    a2dw PROTO :DWORD

    .code       ; code section

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

align 4

a2dw proc String:DWORD

  ; ------------------------------------------------
  ; Convert decimal string into UNSIGNED DWORD value
  ; ------------------------------------------------

    mov edx, [esp+4]
    xor ecx, ecx
    movzx eax, BYTE PTR [edx]
    test eax, eax
    jz quit

  lpst:
    add edx, 1
    lea ecx, [ecx+ecx*4]            ; mul ecx * 5
    lea ecx, [eax+ecx*2-48]
    movzx eax, BYTE PTR [edx]
    test eax, eax
    jz quit

    add edx, 1
    lea ecx, [ecx+ecx*4]            ; mul ecx * 5
    lea ecx, [eax+ecx*2-48]
    movzx eax, BYTE PTR [edx]
    test eax, eax
    jnz lpst

  quit:
    lea eax, [ecx]

    ret 4

a2dw endp

OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

end


Just copy this one directly into the old library module replacing the previous one, save it then rebuild the MASM32 library using the provided batch file MAKE.BAT that is in the m32lib directory.

Rainboy