flat assembler
Message board for the users of flat assembler.

Index > Main > ..

Author
Thread Post new topic Reply to topic
pool



Joined: 08 Jan 2007
Posts: 97
pool 03 Jan 2013, 01:03
..


Last edited by pool on 17 Mar 2013, 12:12; edited 1 time in total
Post 03 Jan 2013, 01:03
View user's profile Send private message Reply with quote
nop



Joined: 01 Sep 2008
Posts: 165
Location: right here left there
nop 03 Jan 2013, 01:37
Code:
mov esp,top_of_stack
 

<rest of code>



top_of_stack:
times 256 db ? ;or whateva size stack u want or need

    
Post 03 Jan 2013, 01:37
View user's profile Send private message Reply with quote
pool



Joined: 08 Jan 2007
Posts: 97
pool 03 Jan 2013, 02:12
..


Last edited by pool on 17 Mar 2013, 12:14; edited 1 time in total
Post 03 Jan 2013, 02:12
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 03 Jan 2013, 03:41
pool wrote:
just that? I thought it be more hard. Can I also do this?:

invoke SomeMemoryAlloc, 256
mov esp, eax

<rest of code>

thanks nop Smile


lol. hahahaha

So where do you want the function to return?

You're using the stack before it's set up.
Post 03 Jan 2013, 03:41
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 03 Jan 2013, 10:27
Now think of it again: stack grows top-down (i.e. to lower addresses), and both examples set esp to the start of memory block.
Post 03 Jan 2013, 10:27
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 789
Location: Adelaide
sinsi 03 Jan 2013, 11:00
nop wrote:
Code:
mov esp,top_of_stack
 

<rest of code>



top_of_stack:
times 256 db ? ;or whateva size stack u want or need

    
Bad
Code:
mov esp,top_of_stack
 

<rest of code>



times 256 db ? ;or whateva size stack u want or need
top_of_stack:


    
Better Very Happy
Post 03 Jan 2013, 11:00
View user's profile Send private message Reply with quote
pool



Joined: 08 Jan 2007
Posts: 97
pool 03 Jan 2013, 11:22
..


Last edited by pool on 17 Mar 2013, 12:14; edited 1 time in total
Post 03 Jan 2013, 11:22
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 03 Jan 2013, 17:01
pool wrote:
So my code would be:
Code:

push 256
call SomeMemoryAlloc ;invoke SomeMemoryAlloc, 256

add eax, 256 ;convert it to higher address for stack setup
mov esp, eax

<rest of code> 

    

hahaha. You need to setup the stack itself first before you call any function. Unless it knows where to return.
Post 03 Jan 2013, 17:01
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 03 Jan 2013, 17:08
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 22:06; edited 1 time in total
Post 03 Jan 2013, 17:08
View user's profile Send private message Reply with quote
pool



Joined: 08 Jan 2007
Posts: 97
pool 03 Jan 2013, 17:28
..


Last edited by pool on 17 Mar 2013, 12:14; edited 1 time in total
Post 03 Jan 2013, 17:28
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 03 Jan 2013, 18:40
Windows will normally allocate separate page regions for each thread stack but the code you have will work too as long as the memory region is a valid read/write area and large enough. In fact, I'm using this to debug thread/virtual-syscall code for my OS project in VS2010.
Post 03 Jan 2013, 18:40
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.