Boot sector doesn't run

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
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Boot sector doesn't run

Post by romfox »

Hello all, first, sorry for my english.

So, I post here cause I have troubles that I didn't had on my last computer : I am actually running on Win7-0x64 and I want to make my own MBR.
I mounted my virtual floppy, put my BIN on, and launch it with Qemu. It works ! But still don't launch my MBR...

My MBR is simple, but to be sure I tried different codes, and I'm sure that Qemu(I have tried with VB too) doesn't launch it. I just have a black window which doesn't move.

I use Virtual Floppy Drive to create virtual floppies.
And the most strange is that I could launch my MBR using this method with my last computer which was in 32 bits... I don't know.

Thank all.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Boot sector doesn't run

Post by Brendan »

Hi,
romfox wrote:So, I post here cause I have troubles that I didn't had on my last computer : I am actually running on Win7-0x64 and I want to make my own MBR.
I mounted my virtual floppy, put my BIN on, and launch it with Qemu. It works ! But still don't launch my MBR...

My MBR is simple, but to be sure I tried different codes, and I'm sure that Qemu(I have tried with VB too) doesn't launch it. I just have a black window which doesn't move.

I use Virtual Floppy Drive to create virtual floppies.
And the most strange is that I could launch my MBR using this method with my last computer which was in 32 bits... I don't know.
I'm sorry to hear your code is having troubles.

If you ever need help, don't forget that you can ask questions on the forums. You can even post source code if you want to (so that people can check for any bugs, etc).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Boot sector doesn't run

Post by romfox »

Thanks for answers :)

This is one of the code I tested from the wiki :

Code: Select all

; boot.asm
   mov ax, 0x07c0
   mov ds, ax
 
   mov si, msg
ch_loop:lodsb
   or al, al ; zero=end or str
   jz hang   ; get out
   mov ah, 0x0E
   int 0x10
   jmp ch_loop
 
hang:
   jmp hang
 
msg   db 'Salut !', 13, 10, 0
   times 510-($-$$) db 0
   db 0x55
   db 0xAA
Is there a type of floppies to use ? I use the Virtual Floppy Driver's default settings.

So I do :

nasmw -f bin boot.asm -o boot.bin
copy boot.bin A:
qemu -L . -boot a -fda A:

It starts but doesn't launch anything.

Thanks.
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: Boot sector doesn't run

Post by Combuster »

copy boot.bin A:
That does not overwrite the bootsector at all. It only places a "boot.bin" at some random location on the floppy.
I suggest you try actually following the instructions in the Babystep1 tutorial instead of inventing your own.
"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 ]
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Boot sector doesn't run

Post by romfox »

Yeah it works ! :)

Now I tried a boot sector which spawn a message, init the drive, read the sectors :

Code: Select all

init_drive:
   xor ax, ax
   int 0x13
   jc init_drive 

   push es
read_drive:
   mov ax, BASE  ; base set as 0x100
   mov es, ax 
   mov ah, 0x02
   mov al, 1
   xor bx, bx
   mov ch, 0   ; No cylinders
   mov cl, 2   ; Read the second segment
   mov dl, [bootdriver]
   mov dh, 0x00 
   int 0x13
   jc read_drive

   pop es
Then I jump to the readed (don't think 'readed' is correct...) where is my kernel.

Code: Select all

jump dword BASE:00
But it looks never launching the kernel because I have an infinite loop on the boot sector's message whenever using the "-no-reboot" Qemu's option.

I tried lot of things, but whithout correct internet connection this is hard. So I tried to copy a simple boot sector which do the same thing but still the same problem.

To make the img file I do :

copy boot.bin/B+kernel.bin/B OS.img

Thanks..

Edit : I tried with VBox, it only spawns 1 time the message but doesn't spawn the kernel's one.
But something gones bad. I know I maybe look like a noob who wants to run before walk, but I'm programming asm since a little moment, and a simple OS (in real mode using BIOS first) will be a good way to learn and have fun I think :)
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Boot sector doesn't run

Post by romfox »

Done :) It was a code error (cause parse code when you have to copy from your phone is hard :p)

Really happy :)

I have one last question now :

When spawning a char to screen whithout using the BIOS, the tuto show that I have to mov AX to ES:DI and I'm not sure I understand.

Does it simply move the char and its properties to ES:DI which is the video memory ? It looks too 'easy'.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Boot sector doesn't run

Post by Brendan »

Hi,
romfox wrote:I have one last question now :

When spawning a char to screen whithout using the BIOS, the tuto show that I have to mov AX to ES:DI and I'm not sure I understand.

Does it simply move the char and its properties to ES:DI which is the video memory ? It looks too 'easy'.
Yes - it stores the character and it's attribute into video display memory (and ES:DI points to the address in video display memory).

Before doing this you should make sure the video card actually is in text mode. Eventually you'd have code to handle things like tracking the current position and scrolling the screen.

Also note that (sooner or later) for modern OSs you typically want to use a graphics mode (where you control individual pixels, and can draw pictures, icons, menus, etc; and aren't limited to pre-supplied text characters or 16 colours). That's where it starts getting more complicated.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Boot sector doesn't run

Post by romfox »

Hi, sorry, couldn't connect before.

So now my OS looks like a... textbox :p
I made a little keyboard driver, but I think it could be nice to sometime can use C. But I got a "cannot perform PE operations on non PE file" or something like that. I know a little about cross compiling, but I don't know which choice to do. I use windows 7 64bits, I think Cygwin could be a good choice.
But will it work ?
Thanks.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Boot sector doesn't run

Post by bluemoon »

romfox wrote:I know a little about cross compiling
WIKI is your friend. See GCC_Cross-Compiler
I suggest to have a look at it before deciding to use or not to use it.
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Boot sector doesn't run

Post by romfox »

Thanks, the question was : Will it work with Cygwin ? Cause I am not sûre I really understand.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Boot sector doesn't run

Post by bluemoon »

I don't know if you can use cygwin host compiler for os development, it might work if you provided enough compiler flags and do it very carefully.

However, you can build a cross compiler on top of cygwin environment, which the procedure and advantages is listed on the wiki link above. and most people here are more familiar with that environment.
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Boot sector doesn't run

Post by romfox »

Thanks, I have to follow the wiki but downloading with an edge connection at 5kb/s... I Will do it at a friend's home... Thanks, m'y OS now handles what is written :) But all in asm....
romfox
Member
Member
Posts: 50
Joined: Wed Nov 16, 2011 8:14 am

Re: Boot sector doesn't run

Post by romfox »

One more question : yesterday I could try my os copying to my external HD, but it doesnt work anymore, I simply use "dd if=os32.img of=\\.\g: bs=512 count=2880", I dont know why cause it worked fine... I have looked if my sectors are really copied and it does...
Post Reply