Page 1 of 1
Bootsector Help!
Posted: Wed Sep 04, 2002 8:53 pm
by beyondsociety
[attachment deleted by admin]
Re:Bootsector Help!
Posted: Wed Sep 04, 2002 8:56 pm
by beyondsociety
Heres the third .inc file I forgot to include:
IF you look at the bootsector I have a value of 596 as my bootsector in bytes.
This is just a test program, eventually I will seperate into two programs.
; Gdt.inc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; DESCRIPTORS ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
gdt_ptr:
dw gdt_end - gdt - 1 ; GDT limit
dd 0 ; GDT linear address
gdt: dw 0 ; limit 15:0
dw 0 ; base 15:0
db 0 ; base 23:16
db 0 ; access byte (descriptor type)
db 0 ; limit 19:16, flags
db 0 ; base 31:24
DATA_SEL equ $-gdt
dw 0xFFFF ; Limit/Length
dw 0 ; Base 0
db 0 ; Base 0
db 0x92 ; present, ring 0, data, expand-up, writable
db 0xCF ; page-granular, 32-bit
db 0
CODE_SEL equ $-gdt
dw 0xFFFF ; Limit/Length
dw 0 ; Base 0
db 0 ; Base 0
db 10011110b ; P=1, DPL=0, DT=0, ?, Code: conforming, exec/read (1,0,0,1,1110)
db 0xCF ; G=1, D=1, 0, AVL=0, 1111=F: Limit/Length (1,1,0,0,1111)
db 0 ; Base 0
REAL_CODE_SEL equ $-gdt
dw 0xFFFF ; Limit/Length
dw 0 ; Base 0
db 0 ; Base 0
db 0x9A ; P=1, DPL=0, DT=0, ?, Code: conforming, exec/read (1,0,0,1,1110)
db 0
db 0 ; Base 0
REAL_DATA_SEL equ $-gdt
dw 0xFFFF ; Limit/Length
dw 0 ; Base 0
db 0 ; Base 0
db 0x92 ; P=1, DPL=0, DT=0, ?, Code: conforming, exec/read (1,0,0,1,1110)
db 0
db 0 ; Base 0
gdt_end:
Re:Bootsector Help!
Posted: Wed Sep 04, 2002 9:27 pm
by Tom
switch to pmode should be:
mov eax, cr0
or eax, 1
mov cr0, eax
it should be eax, not al
Re:Bootsector Help!
Posted: Wed Sep 04, 2002 9:42 pm
by PlayOS
The way you have set ORG = 0x7c00 and DS = 0x0000 means that your jump
jmp CODE_SEL:do_PM + 0x7C00
is jumping 0x7c00 bytes passed your do_PM label it should just be
jmp CODE_SEL:do_PM
I done the same thing until I understood the ORG feature properly.
Also the boot sector might not be found if the 0xaa55 is not at the end of the sector 1, which in your case it is 80+ bytes into the second sector. Some newer BIOSes do not check for this, but I think most still do. You should make it fit into the 512 byte limit.
Good Luck.
Re:Bootsector Help!
Posted: Thu Sep 05, 2002 2:53 am
by Pype.Clicker
Tom wrote:
switch to pmode should be:
mov eax, cr0
or eax, 1
mov cr0, eax
it should be eax, not al
are you a coder or a cut-n-paster ? it will not affect your code to operate OR on the lowest byte of EAX when you only change the first bit !
Re:Bootsector Help!
Posted: Thu Sep 05, 2002 3:03 am
by Pype.Clicker
PlayOS wrote:
Also the boot sector might not be found if the 0xaa55 is not at the end of the sector 1, which in your case it is 80+ bytes into the second sector. Some newer BIOSes do not check for this, but I think most still do. You should make it fit into the 512 byte limit.
Good Luck.
Never heard of any BIOS that would sweep your disk to find 0xaa55 on any sector and read all sectors from the start until that one. BIOS just check the first sector of all its drives and boots the first drive it founds that has aa55 on it ! ...
Re:Bootsector Help!
Posted: Thu Sep 05, 2002 5:15 am
by PlayOS
Pype.Clicker wrote:
Never heard of any BIOS that would sweep your disk to find 0xaa55 on any sector and read all sectors from the start until that one. BIOS just check the first sector of all its drives and boots the first drive it founds that has aa55 on it ! ...
I never intended to suggest this, I was saying that the most BIOSes look at the first sector of the disk and check if the last two bytes match 0xaa55 and if they do they boot from it, the boot sector in question was 80+ bytes to big so the 0xaa55 he had at the end of the file would be pushed into the next sector, so the BIOS would not recognize the disk as a boot disk.
Sorry if I confused anyone.
Re:Bootsector Help!
Posted: Fri Sep 06, 2002 2:56 pm
by beyondsociety
Thanks for the help. It works!, Its still over the 512 byte limit by 63 bytes. I am going to make it two programs so I won't have this Bios not reqonizing the bootsector. I must have a newer bios that supports this because I was still able to run the bootsector with going over 63 bytes.
Re:Bootsector Help!
Posted: Fri Sep 06, 2002 7:12 pm
by PlayOS
PlayOS wrote:The way you have set ORG = 0x7c00 and DS = 0x0000 means that your jump
jmp CODE_SEL:do_PM + 0x7C00
is jumping 0x7c00 bytes passed your do_PM label it should just be
jmp CODE_SEL:do_PM
Just in case anyone else looks at this for help, I should have said that the problem was that
CS = 0x0000 not DS, as DS has nothing to do with a JMP in code ;D