Page 1 of 1

volatile not working ( i think )[FIXED]

Posted: Thu Mar 01, 2007 2:12 pm
by GLneo
hi all, ok, i have this:

Code: Select all

volatile int irq6_state = 0;
void wait_irq6()
{
    while(irq6_state == 0)
        yield(); // give up prossesor
    irq6_state = 0;
}
and when i run it on bochs it just locks up, so i started tracing and found this:

Code: Select all

mov eax, [ds:0xc000afcc] ; which is where irq6_state is
test eax, eax ; weird ???
jnz 0xc00023cd ; most likely out of the loop
call 0xc000442c ; yield();
i'm not sure what is going on, any help welcome

i'm using DJGPP

thx!

Re: volatile not working ( i think )

Posted: Thu Mar 01, 2007 3:47 pm
by nick8325
GLneo wrote:

Code: Select all

mov eax, [ds:0xc000afcc] ; which is where irq6_state is
test eax, eax ; weird ???
jnz 0xc00023cd ; most likely out of the loop
call 0xc000442c ; yield();
That's "if (irq6_state == 0) yield();". Which should be right, assuming there's a jump back to the top of the loop after the call to yield().

Posted: Thu Mar 01, 2007 5:12 pm
by GLneo
but testing eax with eax will never be false!

Posted: Thu Mar 01, 2007 5:33 pm
by B.E
GLneo wrote:but testing eax with eax will never be false!
Yes, but it's jumping if the zero flag is set. (ie when eax = 0, (eax & eax) sets the zeor flag)

Posted: Thu Mar 01, 2007 5:51 pm
by GLneo
O, ok! :oops: