volatile not working ( i think )[FIXED]

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
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

volatile not working ( i think )[FIXED]

Post 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!
Last edited by GLneo on Thu Mar 01, 2007 5:52 pm, edited 1 time in total.
nick8325
Member
Member
Posts: 200
Joined: Wed Oct 18, 2006 5:49 am

Re: volatile not working ( i think )

Post 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().
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post by GLneo »

but testing eax with eax will never be false!
User avatar
B.E
Member
Member
Posts: 275
Joined: Sat Oct 21, 2006 5:29 pm
Location: Brisbane Australia
Contact:

Post 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)
Image
Microsoft: "let everyone run after us. We'll just INNOV~1"
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post by GLneo »

O, ok! :oops:
Post Reply