I am having a problem with reading sectors from floppy. I am creating a virtual floppy image using dd and testing it on Linux, using VirtualBox.
Here is the code:
boot.asm
Code: Select all
[org 0x7C00]
[bits 16]
jmp start
%include "print.inc" ;has the print function
start:
mov ax,0x1000 ;Location in memory to jump to
mov es,ax ;move to es
xor ax,ax ;zero out ax
mov ah,2 ;Bios Function No
mov al,1 ;No. of Sectors
mov ch,1 ;Track to read
mov cl,2 ;Sector to read
mov dh,1 ;Head to read
mov dl,0 ;Drive to read
int 0x13
jc start ;If there was a problem, go back to the beginning
jmp 0x1000:0x0000 ; jump to the memory location
Hello db "Hello",0 ;message to print
TIMES 510-($-$$) db 0
DW 0x55AA
kernel.asm
Code: Select all
jmp _start
%include "print.inc"
_start:
mov si,_Hello
call print
cli
hlt
_Hello db "Hello from the kernel",0
cli
hlt
TIMES 512-($-$$) db 0
Code: Select all
nasm kernel.asm -f bin -o kernel.bin
nasm boot.asm -f bin -o boot.bin
dd if=boot.bin of=image.img conv=notrunc status=noxfer seek=0
dd if=kernel.bin of=image.img seek=1 conv=notrunc status=noxfer
Can someone please explain what I am doing wrong?
Edit: I figured out the solution. Check the third post.