Stack Initialization

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pkd

Stack Initialization

Post by pkd »

I'm currently working on linking ELF object files in my OS,
and i am having trouble setting the stack up properly im loading the registers as follows

mov ax,0x28 //Programs Data Segment
mov ss,ax
mov esp,0x3c0000 //Where I want the stack

and i then call the relocated program which then crashes, the machine resets when it encounters the return(0) instruction if I leave the stack where it already resides the program will run, but I need the stack for the program so i can use c++ commands like <for> and any others that compile using the <lea> command

any help on setting up the stack properly will be appriciated

pkd 15jan2004
Dangermoose

RE:Stack Initialization

Post by Dangermoose »

I presume you dont have int handlers? Therefore it resets because its tripple faulting. This happens when the machine comes across an error, tries to run the handlers but cant, so the only decent thing to do is restart.

Double check your stacks data descriptor within the gdt, its probably not correct to the changed stack address that you want and causing the tripplefault.

Moose.
pkd

RE:Stack Initialization

Post by pkd »

Thanks for the reply.

I do handle exeptions but tested from my kernel segment, and need to allow for been called from another segment (more work),

I have checked my data descriptor and it appears to be correct, so Ill just have to keep trying till i get it right.

bye
pkd.
Post Reply