My question is, why do you need to inhibit interrupts during the following assembly sequence? Won’t the interrupt just save all the registers and bring them back after it is done, so there is no loss of data?
cli
inb (%dx), %al
orb $0x01, %al
outb %al, (%dx)
sti
Yes, it would. However, some I/O ports are time-sensitive and might not work properly if read/write sequence is interrupted. Or the interrupt affects the port somehow (e.g. you’re reading the UART register and a character arrives, triggering the serial interrupt and changing the UART state). Or you could be writing to a port which is itself related to interrupt handling (e.g. the interrupt controller). It’s hard to say if it’s really necessary without more details, but in general it’s better to be safe than sorry.