The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Rain Dog on January 24, 2005, 12:06:01 AM

Title: converting a string to an integer
Post by: Rain Dog on January 24, 2005, 12:06:01 AM
I was trying to work with the hval, sval,uval, val macros and I could not get any of them to work..


I have a string named op1 that holds the characters "5" and is zero terminated, yet all the above conversion macros yeild only 0

what is the correct syntax for these macros?
Title: Re: converting a string to an integer
Post by: Ic3D4ne on January 24, 2005, 12:28:54 AM
Try the "atodw" proc.

Include C:\masm32\m32lib\atodw.asm

Just open that file in notpad, and read the proc instructions.

-Ic3D4ne
Title: Re: converting a string to an integer
Post by: MichaelW on January 24, 2005, 01:07:37 AM
Here is an example (as a console app):

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .486                       ; create 32 bit code
    .model flat, stdcall       ; 32 bit memory model
    option casemap :none       ; case sensitive
    include \masm32\include\windows.inc
    include \masm32\include\masm32.inc
    include \masm32\include\kernel32.inc
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\kernel32.lib
    include \masm32\macros\macros.asm
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
        string db "12345",0
    .code
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    mov   eax, uval(ADDR string)
    add   eax, 1
    print ustr$(eax)
    mov   eax, input(13,10,"Press enter to exit...")
    exit
; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start

Title: Re: converting a string to an integer
Post by: Rain Dog on January 24, 2005, 02:01:49 AM
i had found the problem.

I did not use ADDR
Title: Re: converting a string to an integer
Post by: ofg on January 24, 2005, 06:27:10 AM
Rain Dog,

  Take a look at also,"Iczelion Tutorials ch.31"
  String2Dword  procedure.