flat assembler
Message board for the users of flat assembler.

Index > Main > LOcal Strings in Procs...

Author
Thread Post new topic Reply to topic
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody
What's wrong here?

If I do something like:
Code:
proc someProc
    locals
         someStr db "What?",0
    endl
    lea eax,[someStr]
    ret
endp
    


It will return just a blank string...why?
Post 01 Apr 2008, 00:15
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
i never use proc (too much Ma$m for me), but is it possible that the problem is the string is before the code.
then, the SomeProc word is used as entry in the proc.
then, it will not execute correctly.

Code:

procedure:
somestring db 'what?',0
lea eax,[somestring]
ret

    

there, in this exemple, we see the problem.

don't know if it is the same for proc directive.
Post 01 Apr 2008, 00:30
View user's profile Send private message Visit poster's website Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody
I don't think FASM does the local variables like that, if it did then the code wouldn't work I would get one of those Windows Error things
Post 01 Apr 2008, 01:25
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
then, this kind of coding is all but asm and in my opinion is a fake feature of this great compiler.

the main philosophy of assembly is the output is a mirror of the input.
Post 01 Apr 2008, 01:31
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
itsnobody: The local string is on the stack and is dynamically allocated. Each time the function is called the string uninitialised. Any data must but put there by your code.

The best solution is to put your fixed strings in the data section of your program.
Post 01 Apr 2008, 01:56
View user's profile Send private message Visit poster's website Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody
ok I see, thanks
Post 01 Apr 2008, 02:13
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.