A small x86-64 kernel. Stage 0 goes from real mode to long mode inside the boot sector.
Share one zeroing loop for all three tables: -16 bytes
Browse filesThe tables are contiguous and rep stosw leaves DI just past each one, so a single count of 3 * 4096 / 2 words clears all three.
failing
1 step in 1 ms
1 file changed
+2−8
@@ -31,16 +31,10 @@ start:
3131 and al, 0xFE ; bit 0 would reset the machine
3232 out 0x92, al
3333
34− mov di, PML4 ; clear the PML4
35− mov cx, 4096 / 2
34+ mov di, PML4 ; clear three 4 KiB tables
35+ mov cx, 3 * 4096 / 2
3636 xor ax, ax
3737 rep stosw
38− mov di, PDPT ; clear the PDPT
39− mov cx, 4096 / 2
40− rep stosw
41− mov di, PD ; clear the PD
42− mov cx, 4096 / 2
43− rep stosw
4438 mov word [PML4], PDPT | PRESENT_WRITABLE
4539 mov word [PDPT], PD | PRESENT_WRITABLE
4640 mov word [PD], HUGE | PRESENT_WRITABLE ; 0..2 MiB, identity