does djgpp cache variables

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.
Post Reply
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

does djgpp cache variables

Post 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*/
}
Last edited by earlz on Fri Sep 23, 2005 11:00 pm, edited 4 times in total.
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: does djgpp cache variables

Post by xenos »

Have you declared timer_ticks as volatile? If not, DJGPP doesn't see that it's updated somewhere else...
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: does djgpp cache variables

Post 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
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: does djgpp cache variables

Post 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
Post Reply