Page 1 of 1

Question for DF about the A20 Code

Posted: Fri Sep 15, 2006 11:13 am
by DynatOS
I've noticed with your A20 Wait routines you use jz/jnz then jmp... like below...

Code: Select all

a20wait:
.l0:    in      al,0x64
        test    al,2
        jz      .l2
        jmp     .l0
.l2:    ret


a20wait2:
.l0:    in      al,0x64
        test    al,1
        jnz     .l2
        jmp     .l0
.l2:    ret
Is there any particular reason for this? Is the extra jump designed to eat some clock cycles up (like the 65535 time-out loop)?

Just wondering, as then you could redesign them as such...

Code: Select all

a20wait:
        in      al,0x64
        test    al,2
        jnz     a20wait
ret


a20wait2:
        in      al,0x64
        test    al,1
        jz      a20wait2
ret
I wouldn't want to deviate from your code if there is a particular design approach you took. Any advisement would be appreciated.

PS: Thanks for the great routine :)

Re:Question for DF about the A20 Code

Posted: Fri Sep 15, 2006 12:45 pm
by Candy
You're optimizing a delay loop.

Re:Question for DF about the A20 Code

Posted: Fri Sep 15, 2006 1:07 pm
by Kemp
A sign of insanity as noted when I mentioned something else ;D Though I agree, this one is a fairly obvious optimisation, not even that really as I would have wrote it the suggested way originally. If there was a particular reason I would be quite interested as it would be something I would have missed as well.

Re:Question for DF about the A20 Code

Posted: Fri Sep 15, 2006 6:41 pm
by DynatOS
Candy wrote: You're optimizing a delay loop.
It is less a question about optimization and more about code clarity. If there isn't any reason to indirectly jump (and I can't see the near jump offering that much in the way of clock cycles), then there is no reason for me to use it :)

Just a "bad" force of habit I perform when I go through my code for clean-ups/commenting/refreshing and come across things like this :P

As I said, this was a question directed towards DF, and he is the only one with the correct answer as he is the only one who *really* knows his own design intentions... obviousness or not. Thanks for attempting to assist anyhow ;)