Bootloader help

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.
Locked
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Bootloader help

Post by quanganht »

Need help!

This is my bootloader code

Code: Select all

BITS 16
ORG 0x7C00

start:
	XOR AX, AX
   	MOV DS, AX
	
	MOV [bsDriveNumber], DL

	PUSHA
	MOV SI, loadmsg
	CALL print
	POPA

	MOV AX, 0x1000
        MOV ES, AX
	MOV BX, 0
	
	MOV AH, 0x02
	MOV AL, 0x01

        MOV DL, [bsDriveNumber]
        MOV DH, 0
        MOV CH, 0
        MOV CL, 2

        INT 0x13

	JC err

	MOV SI,donemsg
	CALL print

	MOV DL, [bsDriveNumber]

        JMP 0x1000:0000
err:
	MOV SI, errmsg
	CALL print

hang:
	JMP hang

print:
   	LODSB
   	OR AL, AL
  	JZ done
   	MOV AH, 0x0E
	INT 0x10
   	JMP print
done:
	RET


msg  DB  "No kernel ...", 0
errmsg  DB  "Error in reading 2nd sector ...", 0
loadmsg  DB  "Loading sector 2 ...",13,10, 0
donemsg  DB  "Done loading sector 2 ...",13,10, 0
bsDriveNumber 	DB 0

	TIMES 510-($-$$) db 0
	DB 0x55
	DB 0xAA
And this is kernel code:

Code: Select all

BITS 16

start:
	MOV AX, 0x7C0
        MOV ES, AX
        MOV FS, AX

	CALL Clrscr

hang:
	jmp hang

Clrscr:
	MOV AX, 0x0600
	MOV BH,0x07
        MOV CX,0x0000
       	MOV DX,0x184f
       	INT 10h
	RET

SEGMENT .data
ALIGN 4

msg  DB  "Kernel is running...", 0
I compile them and 'cat' them into one file, which is the floppy image. But it seems like the kernel won't be executed.
"Programmers are tools for converting caffeine into code."
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Another Floppy disk problem

Post by Combuster »

Ask smart questions, don't hijack an existing unrelated thread, and search before posting. There are too many issues with that code that have been mentioned a hundred times before.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Locked