I am just starting to learn x86 assembly language because eventually I want to make my own OS. I wrote a boot sector in fasm and it doesn't load the second sector into memory. Because I just started, there is probably something obvious wrong with the code. Could anyone tell me what I am doing wrong? Could the problem be in the second sector?

use16
org 0x7C00

start:
	jmp	bootit

;**********************************************************;
;*	OEM Parameter block / BIOS Parameter Block        *;
;**********************************************************;

TIMES 0Bh-$+start DB 0

bpbBytesPerSector:  	DW 512
bpbSectorsPerCluster: 	DB 1
bpbReservedSectors: 	DW 1
bpbNumberOfFATs: 	DB 2
bpbRootEntries: 	DW 224
bpbTotalSectors: 	DW 2880
bpbMedia: 	        DB 0xF0
bpbSectorsPerFAT: 	DW 9
bpbSectorsPerTrack: 	DW 18
bpbHeadsPerCylinder: 	DW 2
bpbHiddenSectors:       DD 0
bpbTotalSectorsBig:     DD 0
bsDriveNumber: 	        DB 0
bsUnused: 	        DB 0
bsExtBootSignature: 	DB 0x29
bsSerialNumber:	        DD 0xa0a1a2a3
bsVolumeLabel: 	        DB "BOS FLOPPY "
bsFileSystem: 	        DB "FAT12   "

;----------------------------------------;
;   starting point of bootsector code    ;
;----------------------------------------;
bootit:
	cli

	xor	ax, ax
	mov	ds, ax
	mov	es, ax
	mov	ss, ax
	mov	sp, 0xFFFF

	sti
	mov	cx, 5		;we are going to loop 5 times

mainloop:
	mov	si, msgloading
	call	print		;print the string
	call	crlf		;new line
	loop	mainloop	;loop 5 times because cx decreased each time

	mov	si, msgnext
	call	print
	mov	ah, 0		;procedure to call inside keypress int
	int	0x16		;keypress int

	mov	ax, 0x1000	;read sector to address 0x1000:0
	mov	es, ax
	xor	bx, bx	;Offset to read into (zero because it is cleared)
	mov	ah, 02	;BIOS read sector function
	mov	al, 01	;read one sector
	mov	ch, 01	;Track to read
	mov	cl, 02	;Sector to read
	mov	dh, 00	;Head to read
	mov	dl, 00	;Drive to read
	int 0x13

	jmp	0x1000:0x0000

;---------------------------------------;
; a procedure to display a string;
;---------------------------------------;
print:
	mov ah,0x0E
	mov bh,0x00
	mov bl,0x07

	.nextchar:

	lodsb
	or al,al
	jz .return
	int 0x10
	jmp .nextchar

	.return:
	ret

;------------------------------------------;
; a procedure to make a new line ;
;------------------------------------------;
crlf:
	mov	al, 13
	int	0x10
	mov	al, 10
	int	0x10
	ret

;----------------------------------------;
; some strings and stuff              ;
;----------------------------------------;
msgloading db 'The os is booting!',0
msgnext db 'Press any key to load next sector. . .',0

;-------------------------------------;
; set the BOOT-signature at byte 510. ;
;-------------------------------------;
times 510-($-$$) db 0
dw 0xAA55

If there is nothing wrong with what I did above, then how should the next sector start?

Here is the beginning of the second sector. Is there something wrong with this or is there something I need to add?

use16
org 0x10000
jmp main

main:

I figured it out!!!!!!! :)

I had the track set to one and the second sector is on track zero.
So I changed this

mov	ch, 01	;Track to read

to this

mov	ch, 00	;Track to read

And I added this before the jmp 0x1000:0x0000

mov ax, 0x1000
mov ds, ax
commented: Congrats, and thanks for the feedback of your solution. +33
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.