Write Bin Files To Floppy

Page 1 of 1
[ 5 posts ]
  1. Write Bin Files To Floppy Drive
  2. Write Bin Files To Floppy Disk

First, you need to expand the disk image files; right click them and choose “Extract All Here.”. Run TransMac, insert a blank 1.44 MB floppy into the PC’s floppy disk drive, and right click. #Build bin file: nasm loader.asm -f bin -o loader.bin # Write bin file to floppy dd if=loader.bin bs=512 of=/dev/fd0.

Print viewPrevious topic | Next topic
Disk
AuthorMessage
Post subject: Writing *.bin Files To Floppy in Windows
Member

Joined: Sun Jul 19, 2009 1:48 pm
Posts: 201
Location: Brazil
Hello,
I'm trying to write my OS to an floppy disk, but when i try to boot up, Bochs says that i don't have any OS on that floppy, here is the command that i'm using to write:
#1 Try:
C:Assembly> DEBUG os.asm
-w 100 0 0 1
-q

#2 Try:
C:Assembly> DEBUG os.bin
-w 100 0 0 1
-q

Here is my code:
[BITS 16] ; 16 bit code generation
[ORG 0x7C00] ; ORGin location is 7C00
JMP short main ; Jump past disk description section
NOP ; Pad out before disk description
; ------------------------------------------------------------------
; Disk description table, to make it a valid floppy
; Note: some of these values are hard-coded in the source!
; Values are those used by IBM for 1.44 MB, 3.5' diskette
OEMLabel db 'BERL OS' ; Disk label - 8 chars
BytesPerSector dw 512 ; Bytes per sector
SectorsPerCluster db 1 ; Sectors per cluster
ReservedForBoot dw 1 ; Reserved sectors for boot record
NumberOfFats db 2 ; Number of copies of the FAT
RootDirEntries dw 224 ; Number of entries in root dir
LogicalSectors dw 2880 ; Number of logical sectors
MediumByte db 0F0h ; Medium descriptor byte
SectorsPerFat dw 9 ; Sectors per FAT
SectorsPerTrack dw 18 ; Sectors per track (36/cylinder)
Sides dw 2 ; Number of sides/heads
HiddenSectors dd 0 ; Number of hidden sectors
LargeSectors dd 0 ; Number of LBA sectors
DriveNo dw 0 ; Drive No: 0
Signature db 41 ; Drive signature: 41 for floppy
VolumeID dd 00000000h ; Volume ID: any number
VolumeLabel db 'BERL OS '; Volume Label: any 11 chars
FileSystem db 'FAT12' ; File system type: don't change!
main:
MOV BH, 00h
MOV BL, 07h
MOV AL, 1
MOV BH, 0
MOV BL, 0011_1011b
MOV CX, osmsgend - os_msg ; calculate message size.
MOV DL, 30
MOV DH, 0
PUSH CS
POP ES
MOV BP, os_msg
MOV AH, 13h
INT 10h
JMP wel
wel:
MOV BH, 00h
MOV BL, 07h
MOV AL, 1
MOV BH, 0
MOV BL, 0011_1011b
MOV CX, welcome_end - welcome ; calculate message size.
MOV DL, 32
MOV DH, 2
PUSH CS
POP ES
MOV BP, welcome
MOV AH, 13h
INT 10h
JMP osmsgend
welcome DB 'Welcome !'
welcome_end:
os_msg DB 'BerlOS v0.0.1'
osmsgend:
JMP $
; Boot things
TIMES 510-($-$$) DB 0 ; Fill the rest of the sector with zeros
DW 0xAA55 ; Boot signature

What is Wrong?
Thanks,
Nathan Paulino Campos

_________________
About.Me - Blog


Top
Post subject: Re: Writing *.bin Files To Floppy in Windows
Member

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,
I'm trying to write my OS to an floppy disk, but when i try to boot up, Bochs says that i don't have any OS on that floppy, here is the command that i'm using to write:

I'm not sure how other people do it, but if I were using Windows I'd create a floppy disk image using the assembler, and then use something like RawWrite to transfer it to a floppy disk (and/or use it directly in Bochs).
For an example (for NASM):
org 0
incbin 'boot_loader.bin'
align 512
incbin 'something_else.bin'
times 1440*1024 - $ db 0 ;Some padding

Of course when your project becomes more complex you may need to write your own utilities to create disk images (and other things).
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.


Top

Write Bin Files To Floppy Drive

Write
Post subject: Re: Writing *.bin Files To Floppy in Windows
Member

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2637
Location: Devon, UK
Hi,
While there's probably nothing wrong with Rawrite, I'm just giving you an alternative: I like PartCopy which works very nicely. I have heard about people using MS Debug to do the same thing, but for some reason not many people seem to. I don't know whether that is because there's a problem with it or OS devvers just tend to prefer other utils...
That bit over, let's look at your command line (disclaimer: I guess Debug could overwrite you MBR if not used properly and I am not familiar with it myself, so please double check my command line below before you run anything).
Looking at your command lines below, and firing up help in the Debug program, it says that the format is:
write W [address] [drive] [firstsector] [number]

Thinking about what you want to achieve, should your command line be more like:
-w 0 [drive] 0 1

You seem to supply address=100. I assume this is an offset in to your source file, and you want to copy from byte 0, this should be zero. Next is the drive letter (or number). You provide '0', which I would assume to be the primary hard disk (remember that I am not familiar with Debug, so you may be right on this one). Next, I assume are the sector and length you wish to copy to. I think your parameters here are correct (first sector = 0 (LBA), copy one sector).
Anyway, if the above does not work out, take a look at Rawrite / Partcopy. If you go down the Partcopy route, I think there's a bootsector-copying tutorial on www.osdever.net.
Cheers,
Adam


Top
Bin
Post subject: Re: Writing *.bin Files To Floppy in Windows
Member

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2637
Location: Devon, UK
Hi Nathan,
I have now had a chance to read through some of your other posts. Please do not take this as an insult, but I think you could do with some further background reading to help you understand what is going on.
Take a look at this link. It points to a specific page on Bona Fide OS Dev containing sample code and tutorials for boot sectors and gives some additional background information on the subject of booting. This is where I started out with assembly language and have now become more and more confident (I'd only used HLL's and dabbled with HLA before I found Bona Fide).
When you have the 'Hello World' tutorial up and running on the emulator of your choice (and have it on a real or virtual floppy disk), you have a 512b play area to experiment with. At this point, don't worry about breaking anything (you're on an emulator ). Just have a go with some BIOS int's, have a go at writing your own version of PutString, MemCpy etc... and verify with the emulator that they all work. At this point, have a go at loading your next stage from disk using int 0x13. If something goes wrong, read other tutorials and sample code and have a go at debugging. If you really get stuck, describe the symptoms, copy the Bochs register dump, describe what you have tried along with the exact error details and post it here.
Looking at debugging your sample above, there are really only a few reasons your Bochs will say that it cannot boot the floppy:
1. The boot signature is in the wrong place or is not present (a source file issue).
2. The floppy disk or disk image is not present (a toolchain issue).
3. There is no boot sector on the disk (a toolchain issue).
1 and 2 are very easy to fix. If you are not sure about #1, get yourself a hex editor and check that bytes 510 and 511 of your boot sector are as expected.
You are now left with #3. You can diagnose this issue fairly simply. You know that the bootsector is 512 bytes starting at offset 0. Does the floppy spin up when you attempt the write operation? If so, chances are you are not writing to the correct sector on the disk. Again, a hex editor can help you here (especially if you are using disk images instead of physical disks - see Virtual Floppy Drive). If the boot sector is in the wrong place on the disk surface, verify your command line.
I hope some of this helps - sorry for the size of the post(s)!
Cheers,
Adam


Top
Post subject: Re: Writing *.bin Files To Floppy in Windows
Member

Joined: Sun Jul 19, 2009 1:48 pm
Posts: 201
Location: Brazil
Thanks now i write the floppy and my OS is booting!
Thanks very much!

_________________
About.Me - Blog


Top

Write Bin Files To Floppy Disk

Page 1 of 1
[ 5 posts ]