Problem with for loop
Posted: Sat Jan 28, 2012 12:03 pm
Hi all, I'm new in this forum and since I've found solutions for every my problems in os development I decided to join the comunity.
Now, my problem is with the for loop in same cases:
I wrote (reading some tutorials) the code for the irq interrupts succesfully. The keyboard interrupt put in a global variable the ascii code for the key it has just read. Implementing the getch function I wrote a for loop like "for (; key == 0; ) ;" but is does not work. I changed it with "for(; key == 0; ) putchar('\0');". Ridiculous but it works. In "puthcar" I put some "if" and a "move_cursor" function wich uses "outb".
Another case is when I worked with the CPU clock and I tried to calculate time spending during some instructions. The istructions were some "for (i = 0; i < 1000000; i++) ;" and the "for" exit immediately. I put a "printf("%d\n", i);" in the for and now it works.
My question is why I did have to do that? I really do not know a rational reply...
Has anyone had the same problem?
(Sorry for my probably bad english, I'm italian )
Now, my problem is with the for loop in same cases:
I wrote (reading some tutorials) the code for the irq interrupts succesfully. The keyboard interrupt put in a global variable the ascii code for the key it has just read. Implementing the getch function I wrote a for loop like "for (; key == 0; ) ;" but is does not work. I changed it with "for(; key == 0; ) putchar('\0');". Ridiculous but it works. In "puthcar" I put some "if" and a "move_cursor" function wich uses "outb".
Another case is when I worked with the CPU clock and I tried to calculate time spending during some instructions. The istructions were some "for (i = 0; i < 1000000; i++) ;" and the "for" exit immediately. I put a "printf("%d\n", i);" in the for and now it works.
My question is why I did have to do that? I really do not know a rational reply...
Has anyone had the same problem?
(Sorry for my probably bad english, I'm italian )