Question for DF about the A20 Code

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
DynatOS

Question for DF about the A20 Code

Post 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 :)
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Question for DF about the A20 Code

Post by Candy »

You're optimizing a delay loop.
Kemp

Re:Question for DF about the A20 Code

Post 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.
DynatOS

Re:Question for DF about the A20 Code

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