protected mode works, return to real-mode triple faults
[com32] / src / loader.asm
index 18bd286..b0c13d6 100644 (file)
@@ -73,14 +73,14 @@ _start:
        cld
        mov esi, _ldr_main_start
        mov edi, _main_start
-       lea ecx, [_main_size + 3]
+       mov ecx, _main_size + 3
        shr ecx, 2
        rep movsd
 
        mov ax, 10h
        mov ds, ax
        mov ss, ax
-       mov esp, 200000h
+       mov esp, _main_start
 
        call 8:startup
 
@@ -92,7 +92,7 @@ _start:
        and ax, 0xfffe
        mov cr0, eax
 .jmpcs16:
-       jmp 42h:.loadcs16       ; 42 seg is modifed at the start (TODO)
+       jmp 42h:.loadcs16       ; 42 seg is modifed at the start
 .loadcs16:
        mov ax, fs
        mov ds, ax
@@ -218,19 +218,19 @@ gdt_base dd 0xbadf00d     ; space for GDT linear address
 gdt:   ; 0: null segment
        dd 0
        dd 0
-       ; 1: code - 0/lim:4g, G:4k, 32bit, avl, pres|app, dpl:0, type:code/non-conf/rd
+       ; 1: code - 0/lim:4g, G:4k, 32bit, avl, pres|app, dpl:0, type:code/non-conf/rd (sel: 8)
        dd 0000ffffh
        dd 00cf9a00h
-       ; 2: data - 0/lim:4g, G:4k, 32bit, avl, pres|app, dpl:0, type:data/rw
+       ; 2: data - 0/lim:4g, G:4k, 32bit, avl, pres|app, dpl:0, type:data/rw (sel: 10h)
        dd 0000ffffh
        dd 00cf9200h
-       ; 3: tmp code (will set base before entering pmode)
+       ; 3: tmp code (will set base before entering pmode) (sel: 18h)
        dd 0000ffffh
        dd 00cf9a00h
-       ; 4: tmp data (will set base before entering pmode)
+       ; 4: tmp data (will set base before entering pmode) (sel: 20h)
        dd 0000ffffh
        dd 00cf9200h
-       ; 5: return to real-mode 16bit code segment
+       ; 5: return to real-mode 16bit code segment (sel: 28h)
        dd 0000ffffh
        dd 00009a00h