https://github.com/o8vm/rust_dos
Rust DOS : Creating a DOS executable with Rust
https://github.com/o8vm/rust_dos
Last synced: over 1 year ago
JSON representation
Rust DOS : Creating a DOS executable with Rust
- Host: GitHub
- URL: https://github.com/o8vm/rust_dos
- Owner: o8vm
- License: mit
- Created: 2019-12-14T05:15:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-21T22:40:46.000Z (over 3 years ago)
- Last Synced: 2025-03-24T09:38:42.722Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 8.38 MB
- Stars: 168
- Watchers: 7
- Forks: 13
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rust DOS (Creating a DOS executable with Rust)
It is possible to create a DOS executable or 1st stage bootloader with Rust.
This is a quick demo of creating COM executable for DOS.
## Building
You need a binutils and llvm-tools-preview.
```shell
cargo install cargo-binutils
rustup component add llvm-tools-preview
```
Then you can build the project by running:
```shell
cargo build --release
```
To create a COM executable for DOS, run:
```shell
cargo objcopy --release -- -O binary --binary-architecture=i386:x86 rust_dos.com
```
## Running
You can copy `rust_dos.com` to your DOS image.
examples on Linux
```shell
$ sudo partx -av freedos.img
partition: none, disk: freedos.img, lower: 0, upper: 0
Trying to use '/dev/loop1' for the loop device
/dev/loop1: partition table type 'dos' detected
range recount: max partno=1, lower=0, upper=0
/dev/loop1: partition #1 added
$ sudo mount /dev/loop1p1 /mnt
$ sudo cp rust_dos.com /mnt/
$ sudo umount /mnt
$ sudo partx -dv /dev/loop1
```
Then, you can test it using QEMU:
```shell
qemu-system-i386 freedos.img -boot c
```
You can use the `println!` macro.
Below is an example of HelloWorld:

### Others
dpkey module steals key input processing from DOS and converts scan code to ascii code.
about scan code: see [PS/2 Keyboard - OSDev Wiki](https://wiki.osdev.org/PS/2_Keyboard).
