1 # Demo of reading and writing to disk. 2 # 3 # Steps for trying it out: 4 # 1. Translate this example into a disk image code.img. 5 # ./translate ex9.mu 6 # 2. Build a second disk image data.img containing some text. 7 # dd if=/dev/zero of=data.img count=20160 8 # echo 'abc def ghi' |dd of=data.img conv=notrunc 9 # 3. Familiarize yourself with how the data disk looks within xxd: 10 # xxd data.img |head 11 # 4. Run in an emulator, either Qemu or Bochs. 12 # qemu-system-i386 -hda code.img -hdb data.img 13 # bochs -f bochsrc.2disks 14 # 5. Exit the emulator. 15 # 6. Notice that the data disk now contains the word count of the original text. 16 # xxd data.img |head