64 KB FILE limit in RM?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

64 KB FILE limit in RM?

Post 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
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post by Tyler »

load 64K at a time...
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

"at a time"? I don't understand what you mean...

inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
xsix
Member
Member
Posts: 59
Joined: Tue Oct 24, 2006 10:52 am

Post 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
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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
}
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
xsix
Member
Member
Posts: 59
Joined: Tue Oct 24, 2006 10:52 am

Post 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
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post 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
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post 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.
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

Post by mohammed »

for that we install the A20 line i think so we can you use 1 mb in real mode , right ???
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post 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");


}

Post Reply