NOPs in Entering Long Mode Article

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
User avatar
matt11235
Member
Member
Posts: 286
Joined: Tue Aug 02, 2016 1:52 pm
Location: East Riding of Yorkshire, UK

NOPs in Entering Long Mode Article

Post by matt11235 »

I was reading through Entering Long Mode Directly on the Wiki and I noticed after sending the commands to disable the PIC there are two nop instructions.

Code: Select all

mov al, 0xFF                      ; Out 0xFF to 0xA1 and 0x21 to disable all IRQs.
out 0xA1, al
out 0x21, al
 
nop
nop
Is this in lieu of something like IO_WAIT seen in other articles, just in case the PIC can't keep up? Or does it serve another purpose?

Thanks
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: NOPs in Entering Long Mode Article

Post by BrightLight »

They are there in place of an iowait() function. They give the PICs time to process the data they receive, as the CPU is definitely much faster than any other hardware on-board. IMHO, I prefer to delay using two "out 0x80, al" instructions instead of "nop" or "pause".
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
matt11235
Member
Member
Posts: 286
Joined: Tue Aug 02, 2016 1:52 pm
Location: East Riding of Yorkshire, UK

Re: NOPs in Entering Long Mode Article

Post by matt11235 »

omarrx024 wrote:They are there in place of an iowait() function. They give the PICs time to process the data they receive, as the CPU is definitely much faster than any other hardware on-board. IMHO, I prefer to delay using two "out 0x80, al" instructions instead of "nop" or "pause".
Thanks!
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: NOPs in Entering Long Mode Article

Post by Antti »

I am almost sure that they were put there as a two-instruction window for handling interrupts that may be "on their way" before having a null IDT. There is a small difference between an "IO_WAIT" and an "instruction window with IRQs disabled but interrupts enabled", although they both may be intertwined.
Post Reply