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.
srg_13
Post
by srg_13 » Sat Apr 29, 2006 9:36 pm
I am rewriting my keyboard driver (again) and I have ran into this problem: I have a loop in my getchar() function that waits until a key is pressed:
Code: Select all
while(keypressed!=1)
{
__asm__ __volatile__("hlt");
}
The problem is that this just keeps looping forever. However, for some reason, this following code works perfectly, but it fills the screen with "2"s:
Code: Select all
while(keypressed!=1)
{
__asm__ __volatile__("hlt");
puts("2");
}
I can't get it to work unless I print the 2s.... Why is this?
Thanks,
-Stephen
Colonel Kernel
Member
Posts: 1437 Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:
Post
by Colonel Kernel » Sat Apr 29, 2006 11:01 pm
This is just a wild guess, but did you declare the keypressed variable to be volatile?
Top three reasons why my OS project died:
Too much overtime at work Got married My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
srg_13
Post
by srg_13 » Sat Apr 29, 2006 11:07 pm
Whoops... I accidentally just declared it an int.
Thanks for the quick reply!
-Stephen