flat assembler
Message board for the users of flat assembler.

Index > Windows > [Win32:VB6] Strings

Author
Thread Post new topic Reply to topic
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 02 Dec 2004, 19:19
I would like to convert my VB6 project to ASM to but I don't get how to declare, manipulate and use strings in ASM and their necessary functions like Left() Right() Len().

Many thanks,

cod3b453
Post 02 Dec 2004, 19:19
View user's profile Send private message Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 02 Dec 2004, 20:31
It's a easy
example:
VB:
Code:
....
Dim Name As String first As String
    Name = "Blah Bla" 
    first = Left(Name,4)
....
returned - Blah    


Assemler
Code:
....
mov esi,Name
mov edi,first
cld;-> read symbols left -> right. if you write std (not cld) - exchange the directon, and symbols read right -> left
 mov ecx,4
 repe movsb; -->returned in first - Blah
.....
in data section
Name db "Blah Bla",0
first rb 32    


but sometimes, you must "safe" registers like this Asm str proc examples

Code:
proc str_len,string ;it's proc - like WinAPI proc lstrlenA
    push edi esi;safe registers
    xor eax,eax
    mov edi [string]
    mov ecx,-1
@@: inc ecx
    scasb
    jne @r
    mov eax,ecx
    pop esi edi;restore registers
    return
endp ;returned lenght "string" in eax and ecx

proc copy_strn,dest,source,len ;copied "len" symbols from "source" in "dest"
    push esi edi    
    mov ecx,[len]
    mov esi,[source]
    mov edi [dest]
    rep movsb
    dec edi
    mov byte [edi],0
    pop edi esi
    return
endp    


In Windows you may use lstrcpy, lstrcat, lstrlen and other dll functions - look at SDK documentations; Or strcpy strlen... from msvcrt.dll
JohnFound is created a good str proc library - look at fasm IDE project

But i think that you must read more literature for basic assempler programe, if you wish.
Post 02 Dec 2004, 20:31
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 02 Dec 2004, 21:35
I forgot about lstrlen & lstrcat! Thanks for the quick reply and source code Nickolay - it was very helpful!
Post 02 Dec 2004, 21:35
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.