For this project log, I'll briefly describe how to write a basic bootloader with 8086 assembly using the tools and documentations available on the internet. I'm using Linux, so the steps and tools used are from the Linux perspective.
So, what you need to develop something for x86 real mode? You'll need a set of tools:
- A text editor to write the 8086 assembly. I'm using Pluma which is a lightweight text editor and has support for syntax highlight;
- A assembler to translate the source code to binary. I'm using FASM which is simple and supports the 16-bit mode used for real mode;
- Various emulators to test the generated binary and check if the binary doesn't have errors. The two emulators I'll mostly use are 86Box and DOSBos-X, but I'll use QEMU and Bochs too;
- A tool to write to the sectors of pendrive. I'm using wxHexEditor which supports raw access to the pendrive (you could use the dd command, but for now I prefer to use a GUI to copy the bytes);
- A VGA and BIOS compatible real hardware to test for the problems which don't appear on the emulators (emulators are more forgiving than real hardware).
In addition to these tools, you'll need some good documentation with the descriptions of BIOS interrupts. I recommend the HelpPC Reference Library which describes various BIOS interrupts related to disk, video and keyboard services. Also you'll need a x86 instruction reference, which contains a list of opcodes (there are opcodes which aren't available for the original 8086). When developing for the x86 real mode you can't use DOS interrupts (because DOS isn't running on the pendrive).
The biggest challenge when developing for the x86 real mode: there are various flavors of BIOS, each one with unique features and quirks, so it's important to test on various emulators and real hardwares as much as possible.
The code I'm developing will be divided in two parts: the first stage, which is responsible for loading the sectors of pendrive and showing a message if had a error; and the second stage, which will contain the Befunge-93 interpreter.
With the tools and documentations, I've written some code which loads the sectors on the first stage and prints some text on the second stage. The code is a bit disorganized and not well-commented, so for now I'll show the code and the result on a future project log.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.