Author Topic: a problem on masm32\m32lib\a2dw.asm win7  (Read 3685 times)

Rainboy

  • Guest
a problem on masm32\m32lib\a2dw.asm win7
« on: February 01, 2014, 09:20:54 PM »
 :(
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--

  • Administrator
  • Member
  • ******
  • Posts: 7449
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: a problem on masm32\m32lib\a2dw.asm win7
« Reply #1 on: February 01, 2014, 09:38:40 PM »
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

Code: [Select]
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    .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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Rainboy

  • Guest
Re: a problem on masm32\m32lib\a2dw.asm win7
« Reply #2 on: February 01, 2014, 09:51:57 PM »
thanks for you very much :biggrin: