flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Booting from floppydisk.

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Nyrre



Joined: 26 Feb 2006
Posts: 13
Nyrre 26 Feb 2006, 15:23
Hi, I'm new to these forums Smile.

And my problem is, that I have a bootloader, but I don't know how to write it to a floppydisk so when I boot it, the bootloader would start.

Any advice?
Post 26 Feb 2006, 15:23
View user's profile Send private message Reply with quote
Rohan



Joined: 14 Jul 2005
Posts: 13
Rohan 26 Feb 2006, 19:57
use WinImage to writing on floppy boot sector
Post 26 Feb 2006, 19:57
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 27 Feb 2006, 00:22

_________________
redghost.ca
Post 27 Feb 2006, 00:22
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 27 Feb 2006, 01:01
RedGhost, is right, for a simple bin file, rewrite is easy to use.
Basic Usage (Rawrite):
MS-DOS prompt> RAWRITE [-f <file>] [-d <drive>] [-n(owait)] [-h(elp)]
where: -f <file> - name of disk image file
-d <drive> - diskette drive to use, must be A or B
-n - don't prompt for user to insert diskette
-h - print usage information to stdout

The diskette must be formatted or rawrite will not work.
The contents of the disk do not matter and will be overwritten.

Once you get started, it is easier to use a boot loader like "bootprog" that can load a bin, com, exe (mz) from a floppy put on like any other file from windows or linux etc.
http://alexfru.chat.ru/epm.html#bootprog
Post 27 Feb 2006, 01:01
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 27 Feb 2006, 01:17
http://board.flatassembler.net/topic.php?p=27902#27902

With that method you will produce a COM file instead but that COM file is in fact a floppy boot code installer.
Post 27 Feb 2006, 01:17
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 28 Feb 2006, 17:08
I vote for rawwrite Smile
May I suggest a fast emulator like Qemu? it's a good idea to emulate your OS, and you can 'debug' it as well while it crashes (and doesn't burn somethin'), and you won't need so much 'reboots' which reduce your CPU's life span, would you?
Post 28 Feb 2006, 17:08
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 28 Feb 2006, 17:45
There is a rawwrite with GUI for Windows here:
http://uranus.it.swin.edu.au/~jn/linux/

Reboots (activating the RESET line) will NOT reduce your PC life ...
Only a power down / power up cycle will reduce your PC life span but not much.

Emulators are good but all of the free ones have nasty bugs.

They will be usefull but never forget to test on real hardware (to get a " funny surprise")

IMHO the best non free emulator for OS devel is Virtual PC.
For emulators you can just create a plain binary file with the contet of the floppy. Take care because some emulators expect this file to be exactly 1.44M.
Post 28 Feb 2006, 17:45
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 28 Feb 2006, 17:51
bogdanontanu wrote:
Reboots (activating the RESET line) will NOT reduce your PC life ...
Only a power down / power up cycle will reduce your PC life span but not much.

sorry, I didn't know this

bogdanontanu wrote:
Emulators are good but all of the free ones have nasty bugs.

They will be usefull but never forget to test on real hardware (to get a " funny surprise")

I know, but at least test it after it's stable on the emulator, so you don't test it on the hardware (and it crashes for some reason), and you then blame the hardware for the 'bug' Smile
Post 28 Feb 2006, 17:51
View user's profile Send private message Reply with quote
kake_zinger



Joined: 15 Jul 2004
Posts: 51
kake_zinger 01 Mar 2006, 06:27
If you're on Windows it's easiest to use Debug.

debug yourfile.com

-w 100 0 0 1

That's it. Use ? for help inside Debug you will learn what those number values are. The shown example writes your bootcode to sector 0 of floppy disk A. Address 100 is where Debug likes to load a program by default.

Note: Debug expects the floppy to be formatted! At least on XP it will refuse to write to a blank floppy. So always do a quick format to the floppy first. It took me a while to figure this out.

Also John Fine's Partcopy.exe is a good utility for disk read/write stuff like this, search for it. However Debug is more forgiving as it writes direct from memory as opposed to Partcopy writing file data (if file data size mismatch Partcopy will give an error, debug will happily write any amount of data from memory).
Post 01 Mar 2006, 06:27
View user's profile Send private message Reply with quote
Nyrre



Joined: 26 Feb 2006
Posts: 13
Nyrre 02 Mar 2006, 16:47
Thank you for your advice.
I wrote this bootloader (It's Dex4u's) to floppy:
Code:
org 0x7C00

use16   

start:
        xor   ax, ax
        mov   ds, ax
        mov   es, ax
        mov   ss, ax
        mov   sp, 0x7C00

        cli
        lgdt  [gdtr]

        mov   eax, cr0
        or    al, 0x1
        mov   cr0, eax

        jmp   0x10: protected

use32   

protected:
        mov   ax, 0x8
        mov   ds, ax
        mov   es, ax
        mov   ss, ax
        mov   esp, 0x7C00

        mov   dx, 3F2h
        mov   al, 0
        out   dx, al

        mov byte [es:0xB8000], 'P'

        jmp   $

gdt:        dw    0x0000, 0x0000, 0x0000, 0x0000
sys_data:   dw    0xFFFF, 0x0000, 0x9200, 0x00CF
sys_code:   dw    0xFFFF, 0x0000, 0x9800, 0x00CF
gdt_end:

gdtr:       dw gdt_end - gdt - 1
            dd gdt

times 510- ($-start)  db 0
dw 0xaa55
    

But when I booted, my computer just halted and "_"-character blinked in the lower left corner. What went wrong?
Post 02 Mar 2006, 16:47
View user's profile Send private message Reply with quote
dasyar



Joined: 27 Feb 2005
Posts: 33
dasyar 02 Mar 2006, 18:00
Rawrite starts at the beggining of the disk, 0,0, which is where the bootsector is. To use just type in rawrite and your file name.

As for your program, run it and see what happens.
Post 02 Mar 2006, 18:00
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 02 Mar 2006, 18:47
I have tested the code on 4 pc and it works fine, but if the background was a differant color, then it sounds like your one byte out, as one bytes is for forground and background color and the next is for char.
1. Make shore you were puting [es:0xB8000] not [es:0xB800]
2. If that does not work, Try put this
Code:
mov byte [es:0xB8001], 'P'    

And let us know what it does.
Post 02 Mar 2006, 18:47
View user's profile Send private message Reply with quote
Nyrre



Joined: 26 Feb 2006
Posts: 13
Nyrre 03 Mar 2006, 18:51
I replaced line:
Code:
mov byte [es:0xB8000], 'P'    

with line:
Code:
mov byte [es:0xB8001], 'P'    


Then I used command:
fasm bootloader.asm bootloader.bin

and then I wrote bootloader.bin to floppy with RawWrite.

Then I booted and...The same thing happened, but now three vertical (purple) lines appeared to the upper left corner of my screen.
Post 03 Mar 2006, 18:51
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 03 Mar 2006, 19:21
I do not understand why it does not work on your PC, as it work on all my test PC's.
If i do the "mov [es:0xB8001]" on my pc, i get the "_" flashing and a solid pruple background.
Does the above code print a "P" on any one elses PC ???.
Post 03 Mar 2006, 19:21
View user's profile Send private message Reply with quote
Nyrre



Joined: 26 Feb 2006
Posts: 13
Nyrre 03 Mar 2006, 20:48
Well I try it tomorrow on one of my friend's PC.
Post 03 Mar 2006, 20:48
View user's profile Send private message Reply with quote
Nyrre



Joined: 26 Feb 2006
Posts: 13
Nyrre 04 Mar 2006, 14:33
And the same thing happened on my friend's PC.
Computer halted, and three purple lines appeared to the upper left corner, and "_"-character just blinked in the lower left corner.
Post 04 Mar 2006, 14:33
View user's profile Send private message Reply with quote
kake_zinger



Joined: 15 Jul 2004
Posts: 51
kake_zinger 04 Mar 2006, 14:57
My code segment is type 9a00 not 9800, sorry too lazy to go dig up what that actually means, I even used to understand all that stuff. But all code I've done it's been 9a00 and I did calculate it back then bit by bit.

You're entering pmode without setting tss?

On my code the first priority after jumping to protected mode is to set up the tss with

mov ax,tssseg
ltr ax ;Load task state segment

only after this comes the segment register init and after this comes

lidt [idtr] ;Load idt

I have no idea if that code should work without setting up the tss.

When writing to video mem the upper byte of a word is the color attribute,

mov ah,2 ;Green on black bg
mov al,'A'
mov word [0B8000h],ax

Also some letters can be used as color attribute like 'A@' or 'A ' a space in there.

I don't think you need to specify the segment, you're in protected mode now?

It's different if you're using string ops STOSB/W/D and writing to ES:EDI then you got to know where ES is pointing at.
Post 04 Mar 2006, 14:57
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 04 Mar 2006, 18:46
You did try the
mov [es:0xb8000],'P'
on your friends PC ?.
Post 04 Mar 2006, 18:46
View user's profile Send private message Reply with quote
TDCNL



Joined: 25 Jan 2006
Posts: 56
TDCNL 16 Apr 2006, 10:52
When making a bootable floppy image using WinImage, and then typing "boot image.ima" in DOSBOX, nothing happens at all, unfortunately.

But if I in the same way try to boot dex4u.ima (from dex4u.com) it does work.

Dex4u, are you sure those boot loaders are the same?

_________________
:: The Dutch Cracker ::
Post 16 Apr 2006, 10:52
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 16 Apr 2006, 11:47
@TDCNL, You say you made a bootably floppy image using winimage, but what boot code did you use ?, as DOSBox is only a Dos emulator and so expects a dos layout, as in int 13h for floppy access, also as Dex4u can be run from dos.
The only thing differant in the Dex4u dos box image is the floppy driver users int 13h and not the normal pmode floppy driver.
Also if i remember right, you may need to change the image file ext ??.
Post 16 Apr 2006, 11:47
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.