Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / is there any program that can write files to floppys RAW

Author
Message
Three Score
20
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 30th Jul 2005 10:11
i need a program that can write a file to a floppy disk
but not like rawwrite does

i want it to only write the file to a specified sector rather than copying a image and writing the image to floppy(therefor erasing the floppy)

i have tried making my own but it just wont work(and i still cant figure it out and have been working on it to 1/2 week)

btw
i need this to copy a file to a floppy disk sector and then my os read the file and use it

n00bs will be shot on spot...
It only gets more logical from here(sigh)
David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 30th Jul 2005 20:41 Edited at: 30th Jul 2005 20:42
Here is a little assembly guide I wrote about copying sector data to a floppy disk.

This little demo shows you how to write the boot sector. You could modify the code (assuming you know what you're doing ) to write the data you want. You'll need a UNIX system, and the standard as86.

My tutorial assumes you want to write a piece of assembly code to the disk, called 'boot.o'. Ignore all reference to this


Writing Boot Sector to Floppy
-----------------------------

We have to write a C program that copies our code to first sector of the floppy disk. Here it is:

First, we open the file boot in read-only mode, and copy the file descripter of the opened file to variable file_desc. Read from the file 510 characters or until the file ends. Here the code is small, so the latter case occurs. Be decent; close the file.

The last four lines of code open the floppy disk device (which mostly would be /dev/fd0). It brings the head to the beginning of the file using lseek, then writes the 512 bytes from the buffer to floppy.

The man pages of read, write, open and lseek (refer to man 2) would give you enough information on what the other parameters of those functions are and how to use them. There are two lines in between, which may be slightly mysterious. The lines:

boot_buf[510] = 0x55;
boot_buf[511] = 0xaa;

This information is for BIOS. If BIOS is to recognize a device as a bootable device, then the device should have the values 0x55 and 0xaa at the 510th and 511th location. Now we are done. The program reads the file boot to a buffer named boot_buf. It makes the required changes to 510th and 511th bytes and then writes boot_buf to floppy disk. If we execute the code, the first 512 bytes of the floppy disk will contain our boot code. Save the file as write.c.


To make executables out of this file you need to type the following at the Linux bash prompt.

as86 boot.s -o boot.o

ld86 -d boot.o -o boot

cc write.c -o write

First, we assemble the boot.s to form an object file boot.o. Then we link this file to get the final file boot. The -d for ld86 is for removing all headers and producing pure binary. Reading man pages for as86 and ld86 will clear any doubts. We then compile the C program to form an executable named write.

Insert a blank floppy into the floppy drive and type

./write

The disk will be written, and Voila!

GOOD BYE !

[url=www.lightningstudios.co.uk][/url]
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 30th Jul 2005 21:32
Hey David where did you learn how to do that?


"Lets migrate like bricks" - Me
David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 30th Jul 2005 22:11
Its quite a common method, and I learnt alot from this Linux 'magazine' on the net

I have also just realised, that the way I wrote that is nearly word-for-word to another article on the net. I aslo just realised, that the way this could functions, would make the file non-readable under the OS. Damn

[url=www.lightningstudios.co.uk][/url]
Three Score
20
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 31st Jul 2005 01:55
"You'll need a UNIX system"
well that is why im making this post
and yes i have read that article(making a toy os part2) but i was needing to do this under windows and well windows just dont l;ike opening the floppydisk as a stream and prefers you to use dma(protected mode) or interrupt 13h

i could do it under linux but i have windows as my os and i have a virtual machine with linux 9(and that exact code) but im not wanting to copy things from windows to linux then to the floppydisk in raw

n00bs will be shot on spot...
It only gets more logical from here(sigh)

Login to post a reply

Server time is: 2024-11-27 21:50:20
Your offset time is: 2024-11-27 21:50:20