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
cliis necessary before start routine. -
after
cli, sometimes, they use interrupt! likeint 10hI wonder why they use interrupt aftercliwould it be normal?
1) The only case where
cliis necessary before (or within) a boot sector’s initialisation is if the boot sector might run on 8086. For later CPUs loadingsscauses interrupts to be disabled (postponed) until after the next instruction, which is long enough to loadspand get a validss:spfor a potential IRQ handler to use.2) Software interrupts (e.g.
int 0x10) aren’t IRQs and aren’t disabled bycli. It’s normal to do astisoon after aclito 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.