Weird stack problem
Posted: Wed Aug 31, 2005 5:20 pm
Hi!
I want to change the stack so I can store a list of free 4k pages. I need two stacks, one for pages with addresses less than 16Mb and one for more than 16mb. I wrote a short assembly subroutine(NASM Syntax) which I call from C:
When I run this in Bochs and a real computer, my exception handler reports invalid opcode! I look at the bochs screen and it says unknown opcode and then op=0x53. Maybe it is because my kernel grew from 8kb to 12 kb( do I have to update my linker script? IF so, how?). WHen I take out the ret statement and use jmp $ there is no exception but I can't use that because my computer will hang. Is it because to return back, the computer needs to pop cs and ip off the stack and it can't because the stack is different and it loads garbage into cs and ip then jmps to it? Or is this just some weird thing that has something to do with NASM not creating a correct file.
If I am switching stacks wrong could someone please tell me the correct way?
ps. :sorry if this is too long I am just frustrated
I want to change the stack so I can store a list of free 4k pages. I need two stacks, one for pages with addresses less than 16Mb and one for more than 16mb. I wrote a short assembly subroutine(NASM Syntax) which I call from C:
Code: Select all
[global switchstk]
switchstk:
pop eax
mov esp,eax
ret
If I am switching stacks wrong could someone please tell me the correct way?
ps. :sorry if this is too long I am just frustrated