3 ms·
> That’s maybe 20k cycles for the round trip (read IDT and GDT, go through the whole awful ucode flow, and jump to kernel, then do the work, and the do IRET, wh
by messe 3y ago
> That’s maybe 20k cycles for the round trip (read IDT and GDT, go through the whole awful ucode flow, and jump to kernel, then do the work, and the do IRET, which is, again, amazingly slow).
For comparison to the protected-mode version you've outlined: in real-mode, there's no GDT (all segments are 64 kilobytes in length, with their base address given by the value of the segment register shifted left by 4 bits), and the IDT is actually the IVT, a 1024-byte list of 256 segment:offset addresses that begins at memory address zero. There's no switching from user mode to kernel mode. And all IRET has to do is pop flags, segment and offset from the stack, and jump to it.
In the code above, the biggest bottleneck would be probably be the (VGA)BIOS's implementation of the print character function, which was usually dog slow, as it would look up the current cursor position by querying VGA registers using the x86 port IO instructions, which were quite slow even at the time, and would have to do so for each character.
I wouldn't call it fast, but it's good enough for displaying a few short messages onscreen in an assembly-language program, for example a bootloader.