PAGE_SIZE = 0x1000 PAGE_PRESENT = (1 shl 0) PAGE_WRITE = (1 shl 1) macro page_table_init_real pml4_table* { local page_table ; zero out page table mov edi, pml4_table push di mov ecx, (PAGE_SIZE*4)/4 xor eax, eax cld rep stosd pop di virtual at di label page_table .PML4T rb PAGE_SIZE .PDPT rb PAGE_SIZE .PDT rb PAGE_SIZE .PT rb PAGE_SIZE .sizeof = $ - page_table end virtual ; create first entry mov word [.PML4T], (pml4_table + .PDPT - page_table) or PAGE_PRESENT or PAGE_WRITE mov word [.PDPT], (pml4_table + .PDT - page_table) or PAGE_PRESENT or PAGE_WRITE mov word [.PDT], (pml4_table + .PT - page_table) or PAGE_PRESENT or PAGE_WRITE ; identity map pages push di mov di, (pml4_table + .PT - page_table) mov ax, (PAGE_PRESENT or PAGE_WRITE) @@: mov [di], eax add eax, PAGE_SIZE add di, 8 cmp di, pml4_table + .sizeof jb @b pop di }