Page 1 of 1

How is this ruining the stack!?

Posted: Sat Jul 15, 2006 7:21 pm
by earlz
I am making some floppy code but something is happening in it
can anyone tell me anything that might be happening to cause the stack to get empty?
this simple code

Code: Select all

void FDD_MotorOn(drive){
	if(drive==0){
		outportb(DOR,0x14);
	}else{
		outportb(DOR,0x25);
	}
	wait(500);
}
and if I comment out the wait then it all works good, and I have tested the wait function throughly so its not wait
if I call fdd_motoron in another function then I get "can not pop off of stack" and if I call it at a 1 function higher then I get just a triple fault(no stack error reported)

Posted: Sat Jul 15, 2006 8:02 pm
by ComputerPsi
Are you sure your stack segment isn't conflicting with your data or code segments?

Posted: Sat Jul 15, 2006 8:30 pm
by earlz
I'm pretty sure not but I'll make sure(my stack I think is at the end of my code/data)

ok I changed my stack, which I needed to do anyway but it didn't work

edit:
w00t! now it works! I accidentally typed EBP instead of ESP so yea changign the stack worked
thank you so much!

also I bet that a lot of the other problems I had was because of that too if it can only handle down 9 of these functions(plus about 30 vars)

Posted: Sat Jul 15, 2006 9:28 pm
by digo_rp
I think you have to take care of DMA transfer cuz floppy driver uses below 1MB mark, remember that...