a few question about reading from a floppy
Posted: Wed Jan 20, 2016 1:16 pm
so i wrote a boot loader, and a few things are unclear to me, the code :
the things that unclear is, if i write into a floppy using the following commands (dd):
dd status=noxfer conv=notrunc if=bin/boot.bin of=boot.flp bs=512 count=1 # Writing it to the first disk
dd status=noxfer conv=notrunc if=bin/kernel.bin of=boot.flp bs=512 count=1 seek=1 # Writing to the first disk on the second block
that means im writing to the same floppy in the first block and skipping a sector right? the boot will go into sector 1 and kernel will go to sector 2.
but in my code i dont understand why choose 1000:00h for bx, i mean i know the es and ds are going need that position, but why exactly 1000h, and by filling the first 512 bytes, does that mean, if i read to 513 the kernel? that will work? and what limit the memory of the kernel in the ram?
thanks alot
Code: Select all
[BITS 16]
[ORG 0x7C00]
;Arguments for the 13h interrupt.
xor dx,dx
mov ch,0h
mov cl,02h
mov bx,1000h
mov es,bx
mov bx,0h
;Actual read to RAM.
ReadFloppy:
MOV AH, 02h
MOV AL, 01h
int 13h
JC ReadFloppy ; Fail loading.
;Register pointers to the sector.
mov ax,1000h
mov ds,ax
; Reseting the screen before jumping to the second sector
mov ah,00h
mov al,02h
int 10h
;-----------------------------
jmp 1000h:00h
;-----------------------------
print_kernel_loading_error:
mov ah,0Eh
mov al,[si]
inc si
cmp al,0
jz $
int 10h
jmp print_kernel_loading_error
kernel_load_error_message db "Failed loading kernel...",0
TIMES 510 - ($-$$) db 0
DW 0xAA55
dd status=noxfer conv=notrunc if=bin/boot.bin of=boot.flp bs=512 count=1 # Writing it to the first disk
dd status=noxfer conv=notrunc if=bin/kernel.bin of=boot.flp bs=512 count=1 seek=1 # Writing to the first disk on the second block
that means im writing to the same floppy in the first block and skipping a sector right? the boot will go into sector 1 and kernel will go to sector 2.
but in my code i dont understand why choose 1000:00h for bx, i mean i know the es and ds are going need that position, but why exactly 1000h, and by filling the first 512 bytes, does that mean, if i read to 513 the kernel? that will work? and what limit the memory of the kernel in the ram?
thanks alot