flat assembler
Message board for the users of flat assembler.

Index > Main > check string type?

Author
Thread Post new topic Reply to topic
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog
Hi everybody. I was wondering if their is a way to check what type of string a user passes into a proc. for example I was building a stringcopy proc and I noticed that it works fine on rb strings but fails on dd ? strings. I realized to make it work on dd ? you have to mov each byte into the dd ? string with an extra offset of 4(since it is a double word) so, I guess I could make two different stringcopy procs, but I was wondering if their is a way I can check if I pass a rb or a dd ? in

thanks
Post 28 Jul 2014, 02:06
View user's profile Send private message Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC
the type is usually implied by code. i.e., you make a version for each type that you want to support. you can always add dynamic support (pass in a parameter for type) but if you use a macro mechanism (to switch between rb/rd(dd)) then it won't be a procedure anymore.
Post 28 Jul 2014, 07:05
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
I am not sure I understand your question.
The string by definition is an address of its first character.
So, you have to pass into procedure that address:
Code:
String1 rb 256
String2 db 'This is a string.',0
pStr2   dd String2
...
stdcall StringCopy, [pStr2]   ; passed address of string 2
stdcall StringCopy, String1   ; passed address of string 1
stdcall StringCopy, String2   ; passed address of string 2 (again)
    
Post 28 Jul 2014, 10:23
View user's profile Send private message Send e-mail Reply with quote
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog
I think I got it figured out. Thanks
Post 28 Jul 2014, 14:41
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-2020, Tomasz Grysztar.

Powered by rwasa.