Page 1 of 1

real mode segments

Posted: Fri Aug 12, 2005 9:27 am
by GLneo
hi all, my kernel is at 0x1000 and just got 55 sectors big(so if your counting) it just hit my boot code, so i'm working on putting my kernel at 0x10000 but i need segmenting help, i tried:

Code: Select all

kernel_load:
            mov ax, 0x1
            mov es, ax
            mov bx, 0x0000  // 0001:0000 should be 0x10000?
            mov ax, 1 //  start at one
            mov cx, 70 // load 70 sectors
            call LoadSectors
but bochs says:

Code: Select all

00004313789p[CPU  ] >>PANIC<< prefetch: RIP > CS.limit
00004313789i[SYS  ] Last time is 1123860399
00004313789i[CPU  ] real mode
00004313789i[CPU  ] CS.d_b = 16 bit
00004313789i[CPU  ] SS.d_b = 16 bit
00004313789i[CPU  ] | EAX=000a0000  EBX=00000004  ECX=000a0200  EDX=00000000
00004313789i[CPU  ] | ESP=0000ffb5  EBP=0000ffd9  ESI=00000000  EDI=0000ffe4
00004313789i[CPU  ] | IOPL=0 NV UP DI PL NZ NA PO NC
00004313789i[CPU  ] | SEG selector     base    limit G D
00004313789i[CPU  ] | SEG sltr(index|ti|rpl)     base    limit G D
00004313789i[CPU  ] |  DS:07c0( 0000| 0|  0) 00007c00 0000ffff 0 0
00004313789i[CPU  ] |  ES:0001( 0000| 0|  0) 00000010 0000ffff 0 0
00004313789i[CPU  ] |  FS:0000( 0000| 0|  0) 00000000 0000ffff 0 0
00004313789i[CPU  ] |  GS:0000( 0000| 0|  0) 00000000 0000ffff 0 0
00004313789i[CPU  ] |  SS:9000( 0000| 0|  0) 00090000 0000ffff 0 0
00004313789i[CPU  ] |  CS:c900( 0000| 0|  0) 000c9000 0000ffff 0 0
00004313789i[CPU  ] | EIP=00010000 (0000ffff)
00004313789i[CPU  ] | CR0=0x60000010 CR1=0x00000000 CR2=0x00000000
00004313789i[CPU  ] | CR3=0x00000000 CR4=0x00000000
00004313789i[     ] restoring default signal behavior
00004313789i[CTRL ] quit_sim called with exit code 1
what am i doing???

Re:real mode segments

Posted: Fri Aug 12, 2005 9:32 am
by QuiTeVexat
0x10000 is at 0x1000:0x0000.

Re:real mode segments

Posted: Fri Aug 12, 2005 9:35 am
by Pype.Clicker

Re:real mode segments

Posted: Fri Aug 12, 2005 10:10 am
by GLneo
thx, but now i get:

Code: Select all

00004362560i[FDD  ] read() on floppy image returns 0
00004364234i[FDD  ] read() on floppy image returns 0
00004365908i[FDD  ] read() on floppy image returns 0
00004367582i[FDD  ] read() on floppy image returns 0
00004369256i[FDD  ] read() on floppy image returns 0
00004370930i[FDD  ] read() on floppy image returns 0
00004372604i[FDD  ] read() on floppy image returns 0
00004374278i[FDD  ] read() on floppy image returns 0
00004375952i[FDD  ] read() on floppy image returns 0
00004377626i[FDD  ] read() on floppy image returns 0
00004379300i[FDD  ] read() on floppy image returns 0
00004380974i[FDD  ] read() on floppy image returns 0
00004382648i[FDD  ] read() on floppy image returns 0
00004384322i[FDD  ] read() on floppy image returns 0
00004385996i[FDD  ] read() on floppy image returns 0
00004387670i[FDD  ] read() on floppy image returns 0
00004389344i[FDD  ] read() on floppy image returns 0
00004391018i[FDD  ] read() on floppy image returns 0
00004392692i[FDD  ] read() on floppy image returns 0
00004394366i[FDD  ] read() on floppy image returns 0
00004396040i[FDD  ] read() on floppy image returns 0
00004397028i[CPU  ] write_virtual_checks(): write beyond limit, r/w
00004397028e[CPU  ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
am i writing to far???

Re:real mode segments

Posted: Fri Aug 12, 2005 12:49 pm
by NotTheCHEAT
Dude, did you notice what he said? 0x10000 = 1000:0000h. The physical address (0x10000) in real mode is calculated by multiplying the segment by 16 and adding the offset. The result (in real mode) is a 20-bit address. In pmode, you use descriptor tables and all that stuff to calculate the physical address. But real mode segmented address 1000:0000h is still equivalent to the physical address 0x10000 (even in pmode, physical addresses are static and do not change, only the way they are mapped logically changes). Once again, you should read http://www.osdev.org/osfaq2/index.php/W ... re%20About .