bootloader?
Posted: Fri Nov 21, 2008 11:00 pm
I have wrote this first stage boot loader
However when I do the jump it seems to just keep clearing the screen and displaying
Greetings and welcome ... and Nates BootLoader Stage 1 repeating this indefinitely over and over again. But it should jump to the second sector code below code .
and display This is sector 2!.
Basically I put the first bootloader program on sector 1 of the floppy image and the other program on the 2 sector.
Where did I go wrong.
Note I assumed main floppy device to be at 00h I could have probably got this first from dl but I don't think this is the problem.
I am using boches to run this on a 1.44 floppy image.
I know the floppy image is correct because I cut and pasted it with a hex editor into it.
Code: Select all
org 0x7c00
BITS 16
jmp start
greetings db 'Greetings and welcome ',13d,10d,'$'
BOOTLOADER_NAME db 'Nates BootLoader Stage 1' ,13d,10d,'$'
STARTSECTOR db 2 ;start sector to load
LOADADDRESS dw 8000h ; where to load the sectors into memory
NUMBEROFSECTORS db 1 ; number of bytes to load begining at STARTSECTOR
; this function just clears the screen
clear_screen:
mov ax , 600h ; clear screen scroll up function
mov bh , 7h ; white on black background
mov ch , 0h ;upper line (top)
mov cl , 0h ;left col (far left)
mov dh , 18h ;bottom
mov dl , 4Fh ;far right
int 10h ; do the clearing
ret
; this function should read the second sector of a floppy into memory 0000:8000
readsectors_into_memory:
mov ah , 02h ; read function
mov al , NUMBEROFSECTORS ; number of sectors to read
mov ch , 0h ; cylinder number
mov cl , STARTSECTOR ; starting sector to begin reading from
mov dh , 0h ; head number
mov dl , 00h ;drive for floppy
mov bx , LOADADDRESS ; es:ds-> buffer for where the sectors will be loaded in this case 0000:8000h
int 13 ; execute the interrupt for reading into memory
ret
start:
call clear_screen ;first clear the screen
; display greeting message
mov ah , 13h
mov al , 01h
mov bh , 0h
mov bl , 0Fh
mov dh , 5h
mov dl , 3h
mov cx , greetings
mov bp , cx
mov cx , 22d
int 10h
;display bootloader name message
mov cx , BOOTLOADER_NAME
mov bp , cx
mov cx , 24d
mov dh , 10h
mov dl , 0h
int 10h
call readsectors_into_memory ;should read the second sector of the floppy into 0000:8000h
jmp 0000:8000 ; should jump to the program specified below
; never should get here but if it does hang around
loop_it:
jmp loop_it
However when I do the jump it seems to just keep clearing the screen and displaying
Greetings and welcome ... and Nates BootLoader Stage 1 repeating this indefinitely over and over again. But it should jump to the second sector code below code .
Code: Select all
org 0x8000
BITS 16
jmp start
hello db 'This is sector 2!',13d,10d,'$' ;Put any data here!
start:
;clear screen first
mov ax , 600h ; clear screen scroll up function
mov bh , 7h ; white on black background
mov ch , 0h ;upper line (top)
mov cl , 0h ;left col (far left)
mov dh , 18h ;bottom
mov dl , 4Fh ;far right
int 10h ;do the clearing
; display the string This is sector 2 on the screen
mov ah , 13h
mov al , 01h
mov bh , 0h
mov bl , 0Fh
mov dh , 5h
mov dl , 3h
mov cx , hello
mov bp , cx
mov cx , 16d
int 10h
; loop forever
endsss:
jmp endsss
Basically I put the first bootloader program on sector 1 of the floppy image and the other program on the 2 sector.
Where did I go wrong.
Note I assumed main floppy device to be at 00h I could have probably got this first from dl but I don't think this is the problem.
I am using boches to run this on a 1.44 floppy image.
I know the floppy image is correct because I cut and pasted it with a hex editor into it.