I was trying to mount an audio CD on Gentoo this morning… that was the problem. Audio CDs don’t actually mount. You use an app like Amarok that can play the stuff on it, or something that can read directly from the cdrom.
It was confusing because I was able to slip it into Ubuntu and get a viewable folder containing the audio on the CD. I think that’s pretty confusing if it isn’t actually mounted. But it works.
Now if only I could figure out automounting (not autoplay). I have udev/hal installed and I’ve added myself to the plugdev group as the manual says for automount support, but it seems not to work. I may try writing in some udev rules like it got USB to work, but I’ll read into it more later.
I’m attending an Intro to Computer Systems class which is taught using the DOS debugger and M$ assembler MASM… *gag*. I should’ve checked before I put down the money on the textbook, which is also based on MASM. I don’t know much about assembly – it’s been like black magic to me for a long time – but I know that I could learn much more if we were using open source tools like NASM and GDB. Anyways, getting the fundamentals from this class will be good enough to allow me to jump towards other directions.
For now I’ll have to follow along in class. The assembler and linker are provided by the professor, but I have the problem of not having (and not willing to have) Windows/DOS installed. I struggled on my own for a while before a friendly guy who knows his stuff suggested a solution with FreeDOS and Qemu. The beauty is that you can install FreeDOS on a disk image that you can mount and access from Linux. Here’s what I did.
- Download a copy of FreeDOS. There is a barebones version and a live CD version, the latter which I used. But all that’s needed is the debugger, which should be in both. I went with the live CD version because it also includes vim, which will make it very convenient 🙂
- Install Qemu. Under Gentoo, I had to emerge gcc 3 because Qemu needs to be built with that. Also, I needed to add the sdl use flag so that graphical output is actually enabled (duh). Here’s what I did:
# install gcc 3 alongside gcc 4
emerge -av =sys-devel/gcc-3.4.6-r2
# flagedit's a nice app to set/unset use flags. just emerge flagedit
flagedit app-emulation/qemu-softmmu +sdl
# this should be automatic, but I had to manually switch to gcc 3 before emerging qemu
# this command just lists the available gcc's. you pick one from the list
# at last build qemu
emerge -av qemu
# don't forget to set gcc back to gcc 4 or weird things happen with the system
- Create a disk image to be the FreeDOS hard drive. This command does the trick:
# creates a 128MB image to hold our FreeDOS install
dd if=/dev/zero of=freedos.img bs=1024 count=128000
- Run Qemu to install FreeDOS onto our disk image. This command will boot from CD, where I set up the drive and installed FreeDOS.
qemu -cdrom /path/to/fdfullcd.iso -hda /path/to/freedos.img -boot d
- Once FreeDOS is set up, I mount the freshly baked disk image as a loopback device on my Linux filesystem so that I can transfer the assembly tools over. This command will take care of mounting the FreeDOS disk image:
# notice the offset option. Though it's FreeDOS, it isn't typical vfat so we need this magic number
mount -o loop,offset=32256,user,rw,umask=000 /path/to/freedos.img /path/to/mount
- At this point you can transfer things over, then unmount and boot up FreeDOS via Qemu again. Setting up the assembly tools is as simple as adding them to the path. Do it DOS style:
Then you’re good to go!
Capturing output might still be an issue. I will resort to piping in scripts and capturing output in files that I can collect later on. I don’t know if debug is like GDB where you can dump to files?
My benefactor also mentions concurrently mounting the disk image on Linux and using it with Qemu running. This sounds dangerous yet interesting. I tried it but got I/O errors trying to access from Linux a folder I was making changes in in FreeDOS.
At any rate, I’m going to have a lot of fun learning about assembly!
Sometimes when I peek at source code, I see some headers that give some meta-information about the file eg. a revision control header with a date and ID or maybe a line like this:
# vim: ts=2:sw=2:sts=2
I recognize it immediately as settings for handling tabs in the vim editor, and I thought that it was a nice indicator of what the author of the file used when writing up the file. Actually, these modelines as they’re called are meant to be automatically picked up and used by vim. Add the following to .vimrc:
And when you open a file with the modeline, vim will take and apply those settings.
In the documentation, the modeline setting is supposedly on by default, but I found that I had to explicitly set modeline in .vimrc for modelines to be recognized. The modelines option was already set to 5 by default, though.