Problems with bootloader and small program

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
Jerkko

Problems with bootloader and small program

Post by Jerkko »

I've done a small bootloader and i'm trying to load small program from floppy and execute it, but I can't get it work.

This is a part of my bootloader's code (boot.bin)

Code: Select all

read:
mov   ax,1000h
mov   es,ax
mov   bx,0

mov   ah,2   ;load to es:bx
mov   al,1   ;load 1 sector
mov   ch,1   ;cylinder 0
mov   cl,2   ;sector 2
mov   dh,0   ;head 0
mov   dl,0   ;drive A
int   13h
jc    read   ;error ->read
jmp   1000h:0000
and then the small program (proc.bin)

Code: Select all

[BITS 16]
[ORG 1000h:0]

mov ax, 0000h
mov ds, ax 
mov ah, 0Eh
mov al, 'a'
mov bh, 0
mov bl, 07h
mov cx, 10
int 10h
hang:
jmp hang
times 512-($-$$) db 0
then I try to do something like this:

partcopy.exe C:\nasm\boot.bin 0 200 -f0
partcopy.exe C:\nasm\proc.bin 0 200 -f0 200
partcopy.exe -f0 0 400 1.44

What am I doing wrong? I looked bochs's log and there was these lines

00002397930i[FDD ] read() on floppy image returns 0
00002431656p[CPU ] >>PANIC<< prefetch: RIP > CS.limit
00002431656i[SYS ] Last time is 1112372637
00002431656i[CPU ] real mode

Does this mean the CS value is too big or something like that? Or can't it read the floppy?

P.S I'm sorry about those long code examples.
P.S.S I'm noobie
AR

Re:Problems with bootloader and small program

Post by AR »

Well "read() on floppy image returns 0" followed by a PANIC would make it seem that it can't read the floppy

Your Bochs description file would also be useful, someone else made the mistake of having:

Code: Select all

floppya: 1_44=a.img, status=inserted
When it should have read

Code: Select all

floppya: 1_44=a:, status=inserted
It also looks like your using a 64bit build (RIP=64bit) if you don't realise.
Jerkko

Re:Problems with bootloader and small program

Post by Jerkko »

I have got that problem solved. There was one little mistake.
This line:

Code: Select all

mov ch,1 ; cylinder 0
should be like this:

Code: Select all

mov ch,0 ; cylinder 0
One bit on wrong place and it doesn't work.
Post Reply