OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:10 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Argument passing
PostPosted: Mon Aug 29, 2022 3:02 pm 
Offline
Member
Member

Joined: Thu Jul 14, 2022 9:45 am
Posts: 91
Hello, guys!

I have problem with passing arguments to user mode process. If i do this:
Code:
int *stack = (int *)fr->usersp+4;

All works fine, but if i try to add something to the allocated stack, the stack are brokes:
Code:
frame->usersp = (isUser ? ((int)pmml_alloc(true)+4096) : 0);

The first poping from stack are zero, i use this code for checking valid of stack:
Code:
pop eax
    ; Check if argument exists
    cmp eax,0
    je .exit

And program always jumps to exit label, this means that after the poping from stack done, the register eax are zero.
What i am doing wrong?


Top
 Profile  
 
 Post subject: Re: Argument passing
PostPosted: Mon Aug 29, 2022 3:38 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
Where is your code to add something to the allocated stack?


Top
 Profile  
 
 Post subject: Re: Argument passing
PostPosted: Mon Aug 29, 2022 3:43 pm 
Offline
Member
Member

Joined: Thu Jul 14, 2022 9:45 am
Posts: 91
Octocontrabass wrote:
Where is your code to add something to the allocated stack?

Here is:
Code:
*(--stack) = (int)argv;


Top
 Profile  
 
 Post subject: Re: Argument passing
PostPosted: Mon Aug 29, 2022 3:58 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
That looks fine.

After you add that value to the user stack, do you put the user stack pointer back into the stack frame?


Top
 Profile  
 
 Post subject: Re: Argument passing
PostPosted: Mon Aug 29, 2022 4:03 pm 
Offline
Member
Member

Joined: Thu Jul 14, 2022 9:45 am
Posts: 91
Octocontrabass wrote:
That looks fine.

After you add that value to the user stack, do you put the user stack pointer back into the stack frame?

Ah, yeah i don't update the pointer of stack. Thank now all works fine!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: deblokc and 80 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group