Out Of Room!

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
Tom

Out Of Room!

Post by Tom »

hello, my C Kernel has gotten to 11.5k ( 11k * 2 = amount of sector space taken...on a floppy...right? )

Ok...I load my kernel at 9FFFh when I go higher....NASM tells me that that value is too big :( I neet to load more...I think 14000h is enough...here is my BIOS code:

; Read the floppy drive. Load the FritzOS C Kernel
read:
mov bx, 9FFFh   ; PROBLEM: can't load more stuff
mov ah, 0x02      ; Load disk data to ES:BX
mov al, 25 ; Load 25 sectors ( the size of the kernel. If you add to the kernel, make
            ; that 25 to about 28!

mov ch, 0 ; First Cylinder
mov cl, 2 ; Start at the 2nd Sector (don't load the bootsector, the kernel!)
mov dh, 0 ; Use first floppy head ( stuff for reading the disk)
mov dl, [drive] ; Load from the drive FritzOS booted from.
int 13h ; Read!

    jc read         ; Error, try again( and again)
Schol-R-LEA

Re:Out Of Room!

Post by Schol-R-LEA »

Tom wrote: hello, my C Kernel has gotten to 11.5k ( 11k * 2 = amount of sector space taken...on a floppy...right? )

Ok...I load my kernel at 9FFFh when I go higher....NASM tells me that that value is too big :( I neet to load more...I think 14000h is enough...here is my BIOS code:

; Read the floppy drive. Load the FritzOS C Kernel
read:
mov bx, 9FFFh???; PROBLEM: can't load more stuff
mov ah, 0x02??????; Load disk data to ES:BX
mov al, 25 ; Load 25 sectors ( the size of the kernel. If you add to the kernel, make
????????????; that 25 to about 28!

mov ch, 0 ; First Cylinder
mov cl, 2 ; Start at the 2nd Sector (don't load the bootsector, the kernel!)
mov dh, 0 ; Use first floppy head ( stuff for reading the disk)
mov dl, [drive] ; Load from the drive FritzOS booted from.
int 13h ; Read!

??? jc read?????????; Error, try again( and again)
Actually, there are two problems I see, neither of which quite explain the error you describe, but which would surely cause problems.

First off, you are trying to read too many sectors from a given track and head. In the standard 1.44M floppy geometry, each track has 18 sectors per head, or 36 total sectors per track. In order to read 25 sectors, you'll have to code it to read first 18 sectors from tr0:hd0, then 7 more from tr0:hd1.

However, this should not have caused an assembly error, as it is possible to load the value 25 into AL, and the assembler doesn't know what you're going to do with the register later.

Second, you seem to have a misunderstanding about real mode addressing. From this code fragment, it seems that you have not (as far as I can see) initialized the ES register, and you have set the BX register to offset 9FFFh; assuming that ES is zero, that means that you are loading the program to absolute address 9FFFh.

All well and good, so far, assuming that's where you want it (from what you are saying, you actually mean to put it at 9FFF0h, or 9FFF:0000). the problem is that in real mode, you aren't dealing with absolute addresses, but segment bases and offsets; the effective address is 0000:9FFF. Keep in mind that a segment offset has a maximium size of FFFFh; by placing your kernel entry point at offset 9FFFh, you are crowding it up near the send of the offset range, giving youself only 6000h bytes (24K) out of the 64K available in the segment.

But to continue: I believe that what you wanted to do was:

Code: Select all

         mov es, 9000h???; see below for why not to use 9FFFh
         mov bx, 0           ; ES:BX == 9000:0000
         mov ah, 0x02??????; Load disk data to ES:BX
The reason you don't want to use the segment base of 9FFFh is because it overlaps with the segment beginning at A000h, i.e., the ROM. Mind you, NASM will let you do that without any warning at all; you have to know ahead of time where you can and cannot load your kernel into.

However, this would not give a size mismatch error, either, as it is entirely possible to load 9FFFh into the BX register; after all, it doesn't know what you'll be using it for, does it? Also, what exactly is the error message you are getting, where does it occur, and what line does it come up on? (it may help if you assemble the code with a "%line" pragma at the start of the fragment, so that we could see what the current line number of the error is clearly).
Tom

Re:Out Of Room!

Post by Tom »

I tried 9000h before...it's not a error...can't get more room than 9000h...need something like 14000h but it says I can't go higher...and how can I change the code to load all of head 0 and then about 10 sectors if head 1 also?
Schol-R-LEA

Re:Out Of Room!

Post by Schol-R-LEA »

[attachment deleted by admin]
Tom

Re:Out Of Room!

Post by Tom »

I do reset the disk...just didn't post the code ;)

the disk reset works...but I use alot of data and code...so I run out of room with 9000h...
i'll try that stuff later...
Tom

Re:Out Of Room!

Post by Tom »

your zip archive is messed up :-\ i could get most of the files out if it...but don't know if everything is correct...
Schol-R-LEA

Re:Out Of Room!

Post by Schol-R-LEA »

Just checked it myself, and yeah, some of the files are bad... but both of the source code files seem to be OK, at least with the coy I retrieved off the server, and those were the important ones. The rest are either support files (an extra copy of partcopy and it's readme file, a few batch files for automatically setting up disk images, a blank disk image for loading the binaries into) or files that can be regenerated from the source code (the binaries and listing files). HTH.

One possibility occurs to me: is it possible that you're boot loader is what is too big? If the boot loader exceeds 512 bytes, then the filler data - the extra padding right before the boot signature that usually goes something like

space   times (0x0200 - 2) - ($-$$) db 0

- should return an error saying that the times cannot accept a negativer value, like this one:
[tt]overstuffed.asm:189: error: TIMES value -2 is negative[/tt]

This doesn't sound like the error you are getting, though. Again, more information (error messages, source code) would be helpful.
Tom

Re:Out Of Room!

Post by Tom »

ok...sorry to say this but I do know what i'm doing ;)

I just don't know how to load past 9000h

NASM says sometimes a warning or a error like this I think:

warning: bx somthing something is too big or somthing..

it says I can't load at 1 meg ( i.e. 10000h)

Warmaster can do this...
Tom

Re:Out Of Room!

Post by Tom »

if you want to see all of my code...go to The FritzOS Development Page

and download pk0.6 and open up boot.asm
Schol-R-LEA

Re:Out Of Room!

Post by Schol-R-LEA »

Tom wrote: ok...sorry to say this but I do know what i'm doing ;)

I just don't know how to load past 9000h

NASM says sometimes a warning or a error like this I think:

warning: bx somthing something is too big or somthing..

it says I can't load at 1 meg ( i.e. 10000h)
Well, no, you can't load a value larger than FFFFh into BX at all - it's only a 16-bit register. In any case, 10000h is not 1M, its 65536 (64K +1). 1048576 == 100000h (five zeroes).

In any case, you still don't seem to have grasped the significance of the fact that you are still in real mode at the point in your boot loader where you are doing this (you must be, or the BIOS calls wouldn't work). You don't have 32-bit flat addressing available; far addresses have to be in segment:offset pairs, and the highest address you can get is FFFF:FFFF, or 10FFEFh absolute (1114095 decimal, which is
1M + 64K - 16 bytes; to get to the addresses above 1M you first need to reset the A20 address line, however).
Tom

Re:Out Of Room!

Post by Tom »

ok...i'll try that...
Schol-R-LEA

Re:Out Of Room!

Post by Schol-R-LEA »

Tom wrote: if you want to see all of my code...go to The FritzOS Development Page

and download pk0.6 and open up boot.asm
OK, done... hmmn. This seems to be an older version of the code; it assembles with only a few minor warnings about labels with no colons. Easy enough to fix, that.

Looking at it, I see a few problems immediately, starting with the fact that while DS is initialized, you dont' initialize ES or set up the stack. While it is probably safe to use the stack set up by the BIOS, ES is a different story, because it is used by the INT 13h routines to read data into. Without setting the ES register, it could be loading your code anywhere. Assuming that it is defaulting to 0000, then loading BX with 9000 gives you an address of 0000:9FFF, or 9FFFh absolute. I've already told you what this means - it gives you 6000h bytes (24K) between the entry point of your kernel and the end of the segment it is in - not much room, but still nearly twice as much as you are using.

OK, I tried substituting the code you posted earlier for the code in the boot.asm file, and got - nothing. No error message. Huh? Unless there are other changes you haven't shown me, then I can't see how you'd get an error and I wouldn't. Mind you, I don't see anything that should assemble as an error - logic errors, yes, but not syntax errors - which was why I couldn't figure out the problem earlier, but I'd still expect that if you got an error, then I should be able to reproduce the problem if I have the same code and the same assembler. That's very odd.

I'll try to see if I can get the code as it is working, and get back to you. If you can update the code at fritzOS.sourceforge.net, or post the newer code here, it may help.
Tom

Re:Out Of Room!

Post by Tom »

Ty..it worked! ( DF or Tim Rob...the board is messing up!

I don't get the graphical images ( reply...etc. ) All I get is words like "Smiley" for smily. but all the butons don't work!!!!! )
Post Reply