Arrghh, entering PMode
Posted: Fri Jun 21, 2002 11:00 pm
Here is my code. All I want it to do is enter PMode, then hang. But the computer (well, Bochs) does not like the jmp (I'm using NASMP). Help plz!
[SEGMENT .text]
[BITS 16]
[ORG 7c00h]
;struc interrupt_descriptor
; offset0_15 resw 1 ; low word of handler offset
; selector0_15 resw 1 ; segment selector
; zeroByte resb 1 ; unused in this descriptor format
; iFlags resb 1 ; flag-byte
; offset16_31 resw 1 ; high word of handler offset
;endstruc
start:
mov ax, 0xb800
mov gs, ax
xor eax, eax
mov ax, cs
shl eax, 4
mov [code32Dscr+2], ax
mov [data32Dscr+2], ax
shr eax, 16
mov [code32Dscr+4], al
mov [data32Dscr+4], al
mov [code32Dscr+7], ah
mov [data32Dscr+7], ah
mov [gs:0], byte '1'
lgdt [gdtPtr]
mov eax, cr0
or al, 1
mov cr0, eax
mov [gs:2], byte '2'
jmp dword CODE_SEL:main32
mov [gs:4], byte 'X'
jmp $
[BITS 32]
main32:
mov [gs:4], byte '3'
jmp $
[SEGMENT .data]
;struc segmentDesc
; segLen0_15 resw 1 ; low word of the segment length
; baseAddr0_15 resw 1 ; low word of base address
; baseAddr16_23 resb 1 ; low byte of high word of base addr.
; sFlags resb 1 ; segment type and misc. flags
; access resb 1 ; highest nibble of segment length
; ; and access flags
; baseAddr24_31 resb 1 ; highest byte of base address
;endstruc
gdt dd 0, 0
CODE_SEL equ $-gdt
code32Dscr dw 0xffff, 0
db 0, 0x9a, 0xcf, 0
DATA_SEL equ $-gdt
data32Dscr dw 0xffff, 0
db 0, 0x92, 0xcf, 0
gdtSize equ $-gdt
gdtPtr dw gdtSize
dd gdt
[SEGMENT .text]
[BITS 16]
[ORG 7c00h]
;struc interrupt_descriptor
; offset0_15 resw 1 ; low word of handler offset
; selector0_15 resw 1 ; segment selector
; zeroByte resb 1 ; unused in this descriptor format
; iFlags resb 1 ; flag-byte
; offset16_31 resw 1 ; high word of handler offset
;endstruc
start:
mov ax, 0xb800
mov gs, ax
xor eax, eax
mov ax, cs
shl eax, 4
mov [code32Dscr+2], ax
mov [data32Dscr+2], ax
shr eax, 16
mov [code32Dscr+4], al
mov [data32Dscr+4], al
mov [code32Dscr+7], ah
mov [data32Dscr+7], ah
mov [gs:0], byte '1'
lgdt [gdtPtr]
mov eax, cr0
or al, 1
mov cr0, eax
mov [gs:2], byte '2'
jmp dword CODE_SEL:main32
mov [gs:4], byte 'X'
jmp $
[BITS 32]
main32:
mov [gs:4], byte '3'
jmp $
[SEGMENT .data]
;struc segmentDesc
; segLen0_15 resw 1 ; low word of the segment length
; baseAddr0_15 resw 1 ; low word of base address
; baseAddr16_23 resb 1 ; low byte of high word of base addr.
; sFlags resb 1 ; segment type and misc. flags
; access resb 1 ; highest nibble of segment length
; ; and access flags
; baseAddr24_31 resb 1 ; highest byte of base address
;endstruc
gdt dd 0, 0
CODE_SEL equ $-gdt
code32Dscr dw 0xffff, 0
db 0, 0x9a, 0xcf, 0
DATA_SEL equ $-gdt
data32Dscr dw 0xffff, 0
db 0, 0x92, 0xcf, 0
gdtSize equ $-gdt
gdtPtr dw gdtSize
dd gdt