Author Topic: String to Number...  (Read 3422 times)

0 Members and 1 Guest are viewing this topic.

gerard

  • Guest
String to Number...
« on: 2006-06-11 09:07:21 »
Like it is often that one is in front of the difficult problem to transform a string into a number...(e.g after an enumeration FindNextFile or EnumWindow and so forth...)....

A handle in a listbox in hexadecimal or the size of a file in a listbox...

here is a little progam made in GoAsm64 bits for young it will be easy for them to transform it into a form of MASM 32....

Quote
u1 ---- > length of string
u2 ---- > address of string
u3 ---- > base i.e 10 (decimal) or 16 (hexadecimal)
return value in rax
;==============================================================================
ConvertToNumber FRAME u1,u2,u3
   mov rcx,[u1]
   mov rdx,[u2]
   xor rax,rax
@B:   xor rbx,rbx
   push rdx
   mov rbx,[u3]
   mul rbx
   xor rbx,rbx
   pop rdx
   mov bl,[rdx]
   add rax,rbx
      cmp bl,65
      jl >lll
      sub rax,37h
      jmp >fff
lll:   sub rax,30h
fff:   inc rdx
   dec rcx
   cmp rcx,0
   jne <@B
   ;mov eax,[u1]
   ret
ENDFRAME
;==============================================================================




This message is not at all to ask a question but to give you some ideas...

Try to build a little program with an EditBox receiving the number into hexadecimal form for example...

I let you to your keyboard....

Had fun time...
-----
Gerard