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).