The software which we need is
- nasm
- qemu
Assemble instruction is
nasm print_string.asm -f bin -o print_string.bin
The option -f bin
is telling the assemble to produce raw machine code.
Then we will have a runnable file named print_string.bin
,we can run this OS by
qemu-system-i386 print_string.bin
Switch from 16bit real mode to 32 protect mode:
- define a GDT and it will be loaded into memory;
- using
cli
to disable interrupts; - using instruction
lgdt
then we can save the address of GDT into gdtr; - change the first bit of
CR0
to 1, now we are in 32bit protected mode;