Bootloader jmp problem
Posted: Tue Dec 14, 2010 4:03 am
Hi
I'm italian, english it's not my first language, i'm sorry.
I'm trying to create my own bootloader, following the tutorials in this site.. But it's not working as i wish.
The problem is the jump to the second stage.
When i try to jmp to any type of segment adress, bochs crash or reboot as a infinite loop.
I've just typed the same adress as the tutorial do... but doesn't work.
Why?
What's the matter?
I assemble the asm files with nasm.
i 've created a win32 program that allow me to assemble all files, (assembled with nasm), all in one as a binary image .img.
then i Test all with bochs.
My application simply append one file to another (all files are 512 bytes long, like the floppy sectors)... i have tryed to open the binary image with an hex editor, and it's ok.
this is my code:
stage1.asm
stage2.asm
ok..
Bochs loads the stage1 from the binary floppy image, into 0x07c0 segment adress then...
but nothing happen, I can see only the first stage message, then, not another.
if i try to change the org of the 2nd stage to 0... i see only an infinite loop
if i try to change the segment adress from 0x1000 to another i receive a bochs error message:
prefetch EIP [0001000] > CS.limit [0000ffff]
Can anyone tell me what is the matter please ?
I feel i'm going crazy...
Thanks to all
I'm italian, english it's not my first language, i'm sorry.
I'm trying to create my own bootloader, following the tutorials in this site.. But it's not working as i wish.
The problem is the jump to the second stage.
When i try to jmp to any type of segment adress, bochs crash or reboot as a infinite loop.
I've just typed the same adress as the tutorial do... but doesn't work.
Why?
What's the matter?
I assemble the asm files with nasm.
i 've created a win32 program that allow me to assemble all files, (assembled with nasm), all in one as a binary image .img.
then i Test all with bochs.
My application simply append one file to another (all files are 512 bytes long, like the floppy sectors)... i have tryed to open the binary image with an hex editor, and it's ok.
this is my code:
stage1.asm
Code: Select all
bits 16
org 0
start: jmp main
main:
mov ax,0x07c0
mov ds,ax
mov es,ax
cli
mov ax,0x9000
mov ss,ax
mov sp,0xffff
sti
;output text with Print function [not included]
;then
mov ax,0x1000 ;read into 0x1000 segment
mov es,ax
xor bx,bx ;offset 0x0000
mov ax,0x0201 ;read one sector
mov cx,0x0002 ;track 0 2nd sector
mov dx,0x0000 ;head 0 drive 0= floppy
int 0x13
;check carry flag if not
;print success [not posted]
jmp word 0x1000:0x0000
times 510-($-$$) db 0
dw 0xAA55
Code: Select all
bits 16
org 0x1000
start: jmp main
msg: db "Hello!",13,10,0
Print:
lodsb
or al,al
jz .Done
mov ah,0x0e
int 0x10
jmp Print
.Done:
ret
main:
;print some text with Print function
mov si,msg
call Print
cli
hlt
times 512-($-$$) db 0
Bochs loads the stage1 from the binary floppy image, into 0x07c0 segment adress then...
but nothing happen, I can see only the first stage message, then, not another.
if i try to change the org of the 2nd stage to 0... i see only an infinite loop
if i try to change the segment adress from 0x1000 to another i receive a bochs error message:
prefetch EIP [0001000] > CS.limit [0000ffff]
Can anyone tell me what is the matter please ?
I feel i'm going crazy...
