Stanislaw T
Stanislaw T

Reputation: 420

qemu, get files from host to DOS and also run a bootloader

I need to run some .com files and a bootloader specifically in QEMU. I am running a Win XP machine with a 0.9.0 version of Qemu.

For the .com files I downloaded a MS-DOS 6.22 img and then according to this tutorial: http://gunkies.org/wiki/Installing_MS-DOS_on_Qemu I ran the command:

qemu-img create -f qcow msdos.disk 128M

However it just creates the msdos.disk file of size 1KB.

Then I ran this command:

qemu -hda msdos.disk -m 64 -L . -fda dos622.img -boot a

In the guide it says some sort of installation is supposed to start, but it actually boots something that could be MS-DOS for all I know. It gives me a command line in which i tried to dir, and it showed some .com and .exe files named like MOUSE.EXE and such, as if those were some sort of drivers.

I have been googling for a while and all I found was a bunch of Linux guides.

And first and foremost I do need to compile some .asm files that start with org 100h(.com files) and testrun them in the DOS. So I guess I compile them to produce .o and .bin files. But what next? How do I get them inside the virtual Qemu DOS machine from Win XP?

And a second thing, how do I run a hand-written bootloader when I have the asm code ready? Do I compile it to some sort of an .img somehow? How do I get Qemu to run my bootloader?

I am just baffled by all this and would be really thankful if somebody more knowledgeable could help me in a noob friendly manner.

Upvotes: 1

Views: 1495

Answers (1)

Jester
Jester

Reputation: 58822

For your assembly files, you need to know what assembler they were written for. If they are for nasm then you are lucky, it can directly write a com file for you (it's just a flat binary, so use -f bin).

To get it into qemu, you need to use some tool that allows manipulating raw disk images, such as mtools. You should create and format an image (a floppy for simplicity), then copy your com file onto it. Then you can attach it as a second floppy drive in qemu. If you have enough space in your dos disk, you can of course just copy your com file into that image.

If you have your own boot record, you can just emit that as a flat binary and pass it to qemu as a disk image (make sure it's padded to a multiple of 512 bytes, other than that qemu isn't terribly picky about the size). This is assuming you don't also want a file system, because then you'd have to replace the boot sector somehow. If all else fails, you can grab the windows port of dd.

Upvotes: 1

Related Questions