gdt

How do I enter 32-bit protected mode in NASM assembly?

允我心安 提交于 2019-11-30 05:14:01
问题 I'm learning x86 assembly, and I'm trying to make a toy operating system in NASM, but I don't understand some things. I made a bootloader that is successfully boots my kernel: Loads 14 sectors from the diskette which contains the kernel file; Search a file in these sectors labeled kernel.feo ; Loads that file into the memory to the offset 0x2000 ; Executes the kernel using a far jump jmp 0x2000:0x0000 . So I have the kernel code located at 0x2000:0 in the memory. CS might be properly set

Constant reboot after setting up the Global Descriptor Table and protected mode

我只是一个虾纸丫 提交于 2019-11-27 04:52:34
问题 I must have done something wrong with the GDT setup and the switch to protected mode because it keeps constantly rebooting. Here is my kernel.asm that should setup the GDT and switch to protected mode : bits 16 jmp main %include "gdt.inc" main: cli xor ax,ax mov ds,ax mov es,ax mov ax,0x9000 mov ss,ax mov sp,0xffff sti call InstallGDT cli mov eax,cr0 or eax,1 jmp 08h:Stage3 bits 32 Stage3: mov ax,0x10 mov ds,ax mov ss,ax mov es,ax mov esp,90000h Stop: mov byte [0xb8000],'A' cli hlt and there