Page 1 of 1

does djgpp cache variables

Posted: Fri Sep 23, 2005 11:00 pm
by earlz
I have been creating an OS and really have ran into some very trivial problems
from what i can tell it is as if djgpp is caching variables.
here is my problem; i have an interrupt handler; every timer tick it advances a variable and puts the number of ticks on the screen(for debugging), so i have a little wait function which goes like this

Code: Select all

void wait(int ticks){
ticks=ticks+timer_ticks; /*timer ticks is updated by interrupt, no matter what*/
while (ticks>timer_ticks) /*keep in mind that timer ticks advances every 55ms*/
{/*do nothing*/}
/*and return*/
}
so does djgpp cache its variables or something as from what i can tell this should work

edit:
and now i get an opcode error from this simple code

Code: Select all

void beep(void){
	dword timey;dword t;
	timey=timer_ticks+100;

	while(timey>timer_ticks){}	
/*printf("i"); if you uncomment this then no opcode error and it repeats this command over and over*/
}

Re: does djgpp cache variables

Posted: Sun Sep 25, 2005 11:00 pm
by xenos
Have you declared timer_ticks as volatile? If not, DJGPP doesn't see that it's updated somewhere else...

Re: does djgpp cache variables

Posted: Thu Oct 06, 2005 11:00 pm
by earlz
(sorry for late response)
yes i have now and it still dont work; i even tryed in my while loop using (volatile) to force it,another thing im starting to think djgpp is extremely unstable

Re: does djgpp cache variables

Posted: Fri Oct 07, 2005 11:00 pm
by JAAman
if your running it under windows (esp winXP) then of course its going to be unstable as its written for DOS and uses a special program for PMode programming under DOS which must be emulated under windows -- so basically its running within an emulator - which will always be less stable then native code