loading

Wedding 'save the date' disk with hidden message

Featured
Picture of Wedding 'save the date' disk with hidden message
My now wife came up with a wonderfully nerdy idea to send out 3.5 inch floppy disks as 'save the date' reminders for our wedding. Feeling that my status as 'nerdiest' in the relationship was threatened I thought...

"Wouldn't it be great if we could put a secret message on the disks. Some kind of program that displays a secret message when you boot up your computer with the disk in the drive".

This instructable is a description of how I wrote a helper script in python and a healthy does of 8086 assembly to regain my 'nerdiest' status.
 
Remove these adsRemove these ads by Signing Up

Step 1: Plan

To make the secret message I originally explored a few ideas:

 1. Copy a text and or image file to the disk
 2. Find a copy of some floppy disk linux distro and setup an init script to display a message on boot
 3. Write to the boot sector of the disk and hope someone is silly enough to put the disk in before turning on their computer

Number 1 would have been relatively easy, but not nearly as fun. 2 seemed doable however I had some difficulty finding a working distro and 3 sounded like oh so much fun.

So, the basic plan was to find some way to make a custom 'boot disk' that when the computer is powered on with the disk in the drive a secret message will appear on the screen. For those of you too impatient to read the instructable, you can find the code to make your own secret message floppy disks here:

http://github.com/braingram/floppysecret

Step 2: Dusting off old webpages

After some google searching I found a series of awesome tutorials on linuxgazette.net on 'Writing Your Own Toy OS':
Part 1: http://linuxgazette.net/issue77/krishnakumar.html
Part 2: http://linuxgazette.net/issue79/krishnakumar.html
Part 3: http://linuxgazette.net/issue82/raghu.html

In short, these tutorials detail how to write some assembly code for 8086 type processors (i.e. 386s, 486s, Pentiums, etc...) to do epic things like display a single letter A on screen and more! These actually covered everything I needed to know to display a simple secret message on screen.

Rather than try to duplicate the tutorials I will just highly recommend that you go through at least parts 1 and 2. If you don't have a floppy drive or disks on hand don't worry. I did all of the development and debugging using qemu, a processor emulator, and only burned the resulting image to actual disks when I had worked out most of the bugs.

Step 3: Setting up software

If you're lucky enough to be on a *nix system it's likely that Qemu is available through whatever package manager you use. On ubuntu, you can install it by typing:

sudo apt-get install qemu

or by searching for qemu in the software center (*shiver*). It looks like it may soon be renamed to qemu-kvm

On Macs, last time I checked qemu was available through homebrew (possibly also macports, fink, etc.).

On Windows... not sure. If anyone has a good link, please include it in the comments.

Finally, the source is available at: http://wiki.qemu.org/Download

Other software that you will need includes:
 1. as86 and ld86 (on ubuntu, available in the bin86 package: sudo apt-get install bin86)
 2. gcc
 3. python
 4. make

Here is all of it on one line for you ubuntuers:

sudo apt-get install qemu bin86 gcc python make

Step 4: Working through tutorial part 1

Picture of Working through tutorial part 1
Now that your computer has the necessary software, it's time to work through part 1 of the "Writing Your Own Toy OS" tutorial. Now if you're not using a physical floppy drive you'll have to use a slightly modified write.c that writes the image to a file, not to a floppy.

I will include the text of write.c at the bottom of this step and also attach the file.

Finally, test the image (boot) that you made in the tutorial in qemu. When I first made these images, ubuntu sensibly named the qemu binary 'qemu'. Now, it appears that at least in 12.04 qemu is now 'kvm'. So, if you're not using a recent ubuntu the command you will want to run may be slightly different.

On Ubuntu 12.04:

kvm -fda boot.img

On other platforms where qemu is referred to as... qemu (*sigh*)

qemu -fda boot.img

At this point, a  window should pop up where the first character (eventually) becomes a white A on a black background.

------------------------ write.c -------------------------
#include /* unistd.h needs this */
#include     /* contains read/write */
#include

int main()
{
        char boot_buf[512];
        int floppy_desc, file_desc;

       
        file_desc = open("./boot", O_RDONLY);
        read(file_desc, boot_buf, 510);
        close(file_desc);
       
        boot_buf[510] = 0x55;
        boot_buf[511] = 0xaa;

        floppy_desc = open("./boot.img", O_RDWR | O_CREAT);
        lseek(floppy_desc, 0, SEEK_CUR);
        write(floppy_desc, boot_buf, 512);
        close(floppy_desc);
}

write.c562 bytes

Step 5: What you can do so far

Picture of What you can do so far
So now you can make a boot disk that displays simple characters on screen. The meat of the code is as follows

mov [0],#0x41; set the first character to ascii code 0x41 "A"
mov [1],#0x1f; set the 'attribute' of the first character

The attribute bits set the color of the character and background. 0x1f or %00011111 sets the background to blue (first 4 bits, 0001) and foreground to white (1111). One word of warning here, when i tested this out on a real machine I discovered that at least the computer I used also had a blink bit (woot!). From the following link, it should be bit 7 or (%10000000 = blink).

You can find more info here:
http://geezer.osdevbrasil.net/osd/cons/index.htm

Feel free to do what I did here, and play around with making all sorts of colored text (make all you design friends cry with yellow text on a white background) and display funny things like 'Feed me' etc...

This seemed very promising however I ran into a limitation where the boot sector on a floppy disk is only 512 bytes. This is fine for short messages, however if you want to do something fancier or more complicated you'll have to move on to part 2.

Step 6: Part 2

Picture of Part 2
I'll let part 2 of "Writing Your Own Toy OS" explain all the nitty gritty of getting the computer to run code that is not on the boot sector. Again, you'll have to make a few changes to write.c if you're not using a physical floppy drive (see attachment).

If all you want to do is display a short message than just change the lines:

     mov     cx,#26
and
     .ascii "Handling BIOS interrupts"

Change the 26 to the length of your string + 2 and the text in quotes to your message.

For example, a message like "Hello Human" would be 11 characters long so:

    mov      cx,#13
and
    .ascii "Hello Human"
write.c958 bytes

Step 7: Secret message

Picture of Secret message
The message I ended up displaying was 80x25 characters (standard display size). Rather than writing the assembly directly, I wrote a python script that:

 1. reads in a text file
 2. reads the ascii code of each character
 3. generates the 8086 assembly code for sect2.s to display the characters

The script is terribly ugly, but hopefully with what you've learned from these tutorials, you can change it to your liking. Setting the attr variable at the beginning of the file will change the text attributes (if you don't like the white on pink). Also, if you edit secret.txt you might want to make sure each line has 80 characters so that you fully define what is on screen.

Step 8: Reception

Overall the disks went over quite well. At first, we told no one that they contained anything, hoping that someone would foolishly try to boot it as I probably would :). After a few weeks of suspense (and a few broken disks in the mail) we let people know that the disk was bootable. After that, several people dusted off their old computers, booted up the disks and were quite pleased to find the secret message.

I then proposed a challenge to a few of the more technically inclined invitees and I will pose the same challenge to you. There is a secret within the secret. There is some way to trigger the display of a second secret message (which you can easily find in the code). If you figure out the trigger, please post it in the comments along with a brief description of how you figured it out.

I've attached a zip file containing all the files related to parts 1 and 2 of the 'Writing Your Own Toy OS' tutorial and the final disk image with the 2 secret messages. Happy hunting!
1-40 of 53Next »
SegF4ult3 years ago
I figured out one of the secrets. It's a variation on the Konami code. In sequence you enter the following:

Up Up Down Down Left Right Left Right B A Return

I figured it out by reading and altering gen_asm.py. I took out most of the key compares in the keyloop, then ran a new version of the image and pressed buttons. (I know I could've looked up key constants and whatnot) When I hit UP, I figured that there were some repeats in the sequence that seemed familiar.

Gives you the nice little message "Grow Up! :-)"
braingram (author)  SegF4ult3 years ago
Ding ding ding! We have a winner! Nice work :)
I was just playing around a bit, I wanted to thank you for this instructable. This is actually the first assembler code I've looked at in ages. (I'm not even famliar with x86 assembler to begin with).

You've sparked my interest to keep looking into these things and experiment away .
braingram (author)  SegF4ult3 years ago
This is wonderful to hear!

It gave me a certain sense of glee to move registers around and see results. I'm just glad that I could pass along a little bit of the enjoyment.

Maybe I'll see if I can get a version of tetris working... :)
I'd love to see something alike tetris, it'd be awesome if you could log the development process and maybe post it as an instructable?
Also, on a small note. You hardcoded the text attributes in some lines, so if you're changing the attr value, not all of the screen would be (in my case) blue and white, for example. All it takes is look where text is written and substitute 0xdf or 0x00df for 0x"""+attr+"""

that pretty much fixed up the attribute things.
braingram (author)  SegF4ult3 years ago
Good catch. I'll make the code changes and hopefully spare a few viewers from pink screens.
mtdna3 years ago
What's a 3.5 inch floppy?
Are you serious?
Can you even buy these any more ??
eBay.
braingram (author)  dalmond13 years ago
It was fun trying to find enough of these and of the right colors. We ended up buying some off of ebay and the rest from meritline.com. I do wonder if there are still floppy disk factories out there or if we're just wasting through the remaining stock from the 'age of the floppy'.
I think they've mostly ceased production, although there may be some limited production still going on. I think SONY officially quit making/having made both the drives and the disks.
I don't know if any 3.5 floppies are still being manufactured or not (don't know about 5.25 floppies either. I have a few 5.25 discs and a 5.25 drive on a Windows 2000 computer that is still in daily service) but 3.5s are still available at select retail outlets.
osgeld dalmond13 years ago
sure can, though its getting a bit more difficult ... whats surprising is you can still buy brand new 5.25 inch disks in both HD and DD
I assume it's some new kind of high-density storage medium. I'm excited to hear about it because I'm having trouble carrying my music collection back and forth from work. How many 3.5 inch floppy disks would I need to store my 80Gb mp3 library?
Nope. 3.5" floppies are decades old and were the standard portable data storage medium when I was a kid, however they have long since been rendered obsolete by optical media and flash drives.
osgeld mtdna3 years ago
about 55,556 if you can manage to not waste any space on the disk's
mtdna osgeld3 years ago
Thanks for the help osgeld. Now let's see. 55,556 disks x ~25 grams per disk = ~1400kg = ~3,000lb. Anyone know where I can buy a heavy-duty trailer??

But seriously braingram, your project really is cute. It will be one of the few save-the-dates people don't throw away.
Istarian mtdna3 years ago
Somebody should build a trailer sized jukebox that operates on floppy disks just for the curiousity factor. :P
With redundant floppies for when the die.
Istarian mtdna3 years ago
If you had some kind of weird floppy autoloader, and some kind of floppy stack (bit like slide trays) you might be able to get by with a fridge sized mp3 player given the ~57000 or so floppy disks you'd need. :)
Epic trolling is epic. :D
john3347 mtdna3 years ago
I have single pictures that will not even fit on a 3.5 disc. What is a double density disc - 1.44 MB? (MB - not GB)
wa7jos mtdna3 years ago
I have stacks of 3.5" floppys.
I recently needed to get something off an old laptop that only had a floppy.
Guess what?
Of the 6 other computers in the house, NONE of them had a floppy drive.
Floppy drives have not been standard equipment for many years.
Cute idea, but who's going to have a slot to stick it in?
you know, if you hate the software center THAT much, just use
apt-cache search *
where * is your search term. it should give a readout of various packages that you can install with apt-get.
There's also using Synaptic.
Love it because it uses linux, but who has a floppy drive anymore???
I'm pretty sure you can use a CD.
I do, I have a USB powered floppy drive and a USB powered MAX drive because sometimes I end up getting old software from various places.
srilyk actimm3 years ago
And if you're like me, I have several old floppies whose data I really need to migrate to HD
True, and maybe the generation of people getting these floppies probably still do have floppy drives, but my generation, doesn't even know what a floppy is!!
The really funny thing is that a 3.5" floppy disk isn't actually floppy. That name came about from the really old 8" floppy disks and their smaller, relatively newer cousins the 5.25" floppy disks.

In the late 90's I had a computer builder annoyed at me because I insisted on having my Pentium computer fitted with a 5.25" floppy drive so I could do some of my college AutoCAD and SmartCAM homework at home rather than hanging around the computer lab at my the local community college. That was considered obsolete technology even back then because a 1.44Mb 3.5" drive could hold almost 6 times my SSDD 5.25 floppy.
WuLongTi actimm3 years ago
The "floppy" refers to the actual disc media not the casing for the disc. so the 8, 5.25 and 3.5 discs are all "floppy" since the disc media was a flimsy bit of plastic. As opposed to the "hard" disc found inside your computer that is actually a hard piece of metal.

At least, that was always my understanding of it :)
actimm WuLongTi3 years ago
You are technically correct, the floppy refers to the disk inside of the protective case. That being said, the 8" and 5.25" floppies also had cases that were a lot more flexible than the hard plastic case that was around the 3.5" floppy disk.
I have a hole bunch of 3.5'' floppies, planning on a project, but have never seen a 8'' floppy or even a 5.25'' want to though.
Istarian actimm3 years ago
Heh, me too. I've got a LaCie and Dell USB floppy drive. Got a couple of the internal ones too. I've even got some 5.25" ones.
My thought too.
Love your screen name.
Thanks. Sadly, i misspelled it for reasons i do not know, but ya....
srilyk3 years ago
This instructable is simply *awesome*.

Combining Python, Assembly, and C to make a totally awesome wedding invite is full of win.

Now I wish I had done this when I got married :P
1-40 of 53Next »