Page 1 of 1
64 KB FILE limit in RM?
Posted: Mon Jan 22, 2007 9:27 am
by inflater
Hi,
i am using (un)real mode for my OS and the bootloader can't load a file bigger than 64KB, due to real mode limits. But how can (MS-),(Free-),(DR-) DOS load a executable bigger than 64KB? DOS is real mode, no? Thanks for advice.
inflater
Posted: Mon Jan 22, 2007 9:31 am
by Tyler
load 64K at a time...
Posted: Mon Jan 22, 2007 9:35 am
by inflater
"at a time"? I don't understand what you mean...
inflater
Posted: Mon Jan 22, 2007 10:28 am
by xsix
You can't load file bigger than 64kb? in real mode it is because of then segment limit. Anyway why you can't load bigger? Maybe you're using 16bit values for loading, as CX for how much bytes to load, and the MAX value will be 64, so just load file as pieces of binary
Posted: Mon Jan 22, 2007 10:38 am
by Dex
MiniDos is limted because the segment is hard coded, but if you look at the code for Bootprog
http://alexfru.chat.ru/epm.html#bootprog
Still realmode but it can load bigger files.
Posted: Mon Jan 22, 2007 10:55 am
by Combuster
The basic idea behind it all is this: (hope this pseudocode reads easier than source code)
Code: Select all
while (there_is_more_data)
{
LoadNext64K();
Segment += (64 * 1024 / 16); //next location to write = 64k further = 64k/16 segment units further
}
or alternatively:
Code: Select all
while (there_is_more_data)
{
LoadNextSector();
Segment += (512 / 16); // 512 bytes for a sector, segments go in 16 bytes
}
Posted: Mon Jan 22, 2007 11:02 am
by xsix
but your os is working in voodoo mode, so it can access up to 4gb of ram? and cs, ds, es, fs, gs limits should be 4gb, not 64kb. ONLY if you've changed
Posted: Mon Jan 22, 2007 11:18 am
by inflater
The OS can access 4GB of ram, but after kernel boot... I use the executing functions in interrupts. Interrupts are set in kernel BOOTloader. So my OS can't access more of 4 GB RAM in bootloader...
inflater
Posted: Fri Jan 26, 2007 2:53 pm
by XCHG
Well I really don't understand why you would want to load an executable file in your boot loader. I mean how many bytes of space do you have for handling such thing?
However, if you like to load executable files bigger than the limit of a segment in RM, you should use either contiguous or scattered segment addresses that you know are not being used. Skip the BDA and other well-known used segments. Keep track of the segment locations and change the CS:(E)IP accordingly.
Posted: Sat Jan 27, 2007 2:06 pm
by mohammed
for that we install the A20 line i think so we can you use 1 mb in real mode , right ???
Posted: Sat Jan 27, 2007 4:10 pm
by earlz
ok...though you can use the 64k segmenting, in unreal mode you actually don't have to..
for example:
Code: Select all
void LoadNextSector(void *512b_buffer_realmode);
unsigned char buffer[512];
//main loop
while(more_data){
LoadNextSector(buffer);
__asm(".intel_syntax noprefix\n"
"mov ax,0\n"
"mov gs,ax\n" //we use an extra segment to keep from screwing up C
"mov cx,512\n"
"mov si,buffer\n"
"mov ebx,my_32bit_place\n" //my_32bit_place should be the EFFECTIVE ADDRESS of where you want to place the data
//to figure out effective address for inside of 1MB you just do address=offset+(segment<<4)
"my_loop:\n"
mov ax,[ds:si]\n"
"mov [gs:ebx], ax\n"
"add si,2\n"
"loop my_loop\n"
".att_syntax\n");
}