cli before start in bootloader
assembly, bootloader, x86
Solution
1) The only case where `cli` is necessary before (or within) a boot sector's initialisation is if the boot sector might run on 8086. For later CPUs loading `ss` causes interrupts to be disabled (postponed) until after the next instruction, which is long enough to load `sp` and get a valid `ss:sp` for a potential IRQ handler to use.
2) Software interrupts (e.g. `int 0x10`) aren't IRQs and aren't disabled by `cli`. It's normal to do a `sti` soon after a `cli` to avoid messing up IRQs. When you're trying to squeeze something in 512 bytes it's normal to do silly things that no sane programmer would consider allowing (like leaving interrupts disabled) just to squeeze an extra byte of code in.
Problem
I found 512 byte os contest during web surfing. everything is fitted in bootsector. after read some of those source files, I found there is always `cli` instruction before start routine. (in assembly) ``` use16 org 7c00h jmp 0:start start: cli do something here..(this section sometimes include int 10h) ``` the thing I wonder is why `cli` is necessary before start routine. after `cli`, sometimes, they use interrupt! like `int 10h` I wonder why they use interrupt after `cli` would it be normal?