Page 2 of 2

Re:Help with code

Posted: Wed Nov 13, 2002 4:29 pm
by beyondsociety
Here's the modified code that I'm having problems with. Could someone look over my code and tell me whats wrong with it. Thanks in advance.

Code: Select all

[BITS 16]
[ORG 0x7C00]

              ; Initialize Segment Regs

              xor ax, ax
              mov ds, ax

              mov es, ax
              mov fs, ax
              mov gs, ax

              mov [bootdrv],dl

              ; Setup a Real Mode Stack
              
              cli
              mov ax, 0x9000
              mov ss, ax              
              mov sp, 0xFFFE
              sti

              cli

              lgdt [gdtr_ptr]

              mov eax,cr0
              or  eax,1
              mov cr0,eax

              jmp 0x08:enter_pmode

[bits 32]
enter_pmode:

              mov ax,0x10
              mov ds, ax
              mov es, ax
              mov fs, ax
              mov gs, ax
              mov ss, ax

              jmp $

;----------------------------------------------------------------------
; Global Descriptor Table (GDT)
;----------------------------------------------------------------------

; The GDTR Limit and Base
gdtr_ptr:
              dw 0xFFFF
              dd 0

; The GDT Setup Entries
gdt_start:
              ; Null Segment Descriptor, 0x00

              dd 0         
              dd 0

              ; Code Segment Descriptor, 0x08

              db 11111111b   ; 4GB Limit
              db 11111111b   ; 4GB limit
              db 00000000b   ; Base 0
              db 00000000b   ; Base 0
              db 00000000b   ; Base 0
              db 10011010b   ; Present : Ring 0 : Code\Exec : Non-Conforming : Readable
              db 11001111b   ; 4KB Granularity : 32Bit : 4GB Limit
              db 00000000b   ; Base 0

              ; Data Segment Descriptor, 0x10

              db 11111111b   ; 4GB Limit
              db 11111111b   ; 4GB limit
              db 00000000b   ; Base 0
              db 00000000b   ; Base 0
              db 00000000b   ; Base 0
              db 10010010b   ; Present : Ring 0 : Data : Expand Up : Writable
              db 11001111b   ; 4KB Granularity : 32Bit : 4GB Limit
              db 00000000b   ; Base 0

gdt_end:

;----------------------------------------------------------------------
; DATA
;----------------------------------------------------------------------

              bootdrv   db 0

              times 510-($-$$) db 0           
              dw 0xAA55                       

Re:Help with code

Posted: Wed Nov 13, 2002 5:48 pm
by Curufir
You've setup gdt_ptr wrong.

Curufir

Re:Help with code

Posted: Wed Nov 13, 2002 6:14 pm
by Tom
you could try my GDT ( actually, frank made it for me )

Re:Help with code

Posted: Wed Nov 13, 2002 7:02 pm
by PlayOS
Simple solution, just change this

Code: Select all

; The GDTR Limit and Base
gdtr_ptr:
              dw 0xFFFF
              dd 0
to this

Code: Select all

; The GDTR Limit and Base
gdtr_ptr:
              dw 0xFFFF
              dd gdt_start
Problem Solved, Good Luck!

Re:Help with code

Posted: Thu Nov 14, 2002 12:33 pm
by beyondsociety
Thanks for the help playOS. It works! :D