I was taking a look through some old bootsectors i had before formatting the
floppy disk that contained them, and decided i wanted to use one, because i
remember all the fun i had trying to get pmode to work. As i looked through
a log of my work, i soon came to see that only on of them ever acttually
worked, so i compiled it with nasm and wrote it to a floppy, to my "suprise"
it didnt work. So i scrapped and began to write a new bootsector, same
problem. Being the creative person i am i went online to see if a could
borrow some code from a tutorial that would work. This didnt work either. So
now im SOL. The code i am using is from john fines tutorial i think and is
posted below. The first A acttually shows up, but after that nothing, I
think it used to triple fault not sure if it does anymore, just hangs and no
second "a"
Thanks for all your help.
MOV AX, 0x07C0 ; This is where we are
MOV DS, AX ; Set it up so we know where we are
MOV [BOOTDRV], DL
MOV SI, MSG
CALL PUTSTR
; Gotta have a stack....
MOV AX, 0x9000 ; Put stack at 0x90000
MOV SS, AX ; SS = 9000 and
MOV SP, 0 ; SP = 0000
.... a20 and other misc working routines .....
mov ax,0xB800
mov gs,ax ; point gs to video memory
mov word [gs:0],0x641 ;display 'a'
mov ah,00h
cli ; disable interupts
o32 lgdt [gdtr] ; load the global descriptor table
mov eax,cr0
or al,1
mov cr0,eax ; set PE bit to 1
mov ax,0xB800
mov gs,ax ; point gs to video memory
mov word [gs:0],0x642 ;display 'b'
mov ah,00h
jmp codesel:go_pm
[bits 32]
go_pm: ; address in rm 0000:16-bit offset go_pm
; address in pm 0010:32-bit offset go_pm
; address physical 0000:32-bit offset go_pm
mov ax,datasel
mov ds,ax ; point gs to dataseg
mov es,ax
mov ax,videosel
mov gs,ax ; point gs to videomemory
mov word [gs:0],0x741 ; display 'a'
spin: jmp spin ; loop
......... other misc routines here ......
[bits 16]
gdtr
dw gdt_end-gdt-1; length of gdt
dd gdt ; linear, physical address of gdt
gdt
nullsel equ $-gdt ; 0h = 000b
gdt0 ; null descriptor
dd 0
dd 0
codesel equ $-gdt ; = 8h = 1000b
code_gdt ; code descriptor 4 GB flat segment starting 0000:0000h
dw 0ffffh
dw 0h
db 0h
db 09ah
db 0cfh
db 0h
datasel equ $-gdt ;=10h = 10000b
data_gdt ; data descriptor 4 GB flat segment starting 0000:0000h
dw 0ffffh ; limit 4 GB
dw 0h ; Base 0000:0000h
db 0h
db 092h
db 0cfh
db 0h
videosel equ $-gdt ;= 18h = 11000b
dw 3999 ; limit 80*25*2-1
dw 0x8000 ; base 0xB8000
db 0x0B
db 0x92 ; present, ring 0, data, expand-up, writable
db 0 ; byte-granular, 16-bit
db 0
gdt_end
Help with pmode
RE:Help with pmode
I think I know that's your problem. Look the code after you loaded the GDT and you set the PE bit in CR0: you write the character 'b' on the screen.
You can't do this without setting up the gs register with a correct _32bit_ selector.
Solution:
Once loaded the GDT and set the PE bit, jump to the new code secletor "jmp codesel:go_pm", set the data selector to ds and es and set the video selector to gs. Now it should work.
You can't do this without setting up the gs register with a correct _32bit_ selector.
Solution:
Once loaded the GDT and set the PE bit, jump to the new code secletor "jmp codesel:go_pm", set the data selector to ds and es and set the video selector to gs. Now it should work.