about summary refs log tree commit diff stats
path: root/apps/bos/print-mem-real-mode.hex
diff options
context:
space:
mode:
Diffstat (limited to 'apps/bos/print-mem-real-mode.hex')
-rw-r--r--apps/bos/print-mem-real-mode.hex67
1 files changed, 67 insertions, 0 deletions
diff --git a/apps/bos/print-mem-real-mode.hex b/apps/bos/print-mem-real-mode.hex
new file mode 100644
index 00000000..5e41d5b3
--- /dev/null
+++ b/apps/bos/print-mem-real-mode.hex
@@ -0,0 +1,67 @@
+# Experiment: write to video RAM from 16-bit real mode. And it works.
+#
+# To convert to a disk image:
+#   ./bootstrap run apps/hex < apps/bos/print-mem-real-mode.hex > boot.bin
+# To run:
+#   qemu-system-i386 boot.bin
+# Or:
+#   bochs  # reads bochsrc, which loads boot.bin
+
+# - figure 4.1 of https://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf in protected mode
+# edx <- 0xb8000
+# al <- 'H'
+# ah <- 0x0f  # white on black
+# *edx <- ax
+
+# - translating to real mode
+# bx <- 0xb800
+bb 00 b8
+# ds <- bx
+8e db  # 11b/mod 011b/reg/ds 011b/rm/bx
+# al <- 'H'
+b0 48
+# ah <- 0x0f  # white on black
+b4 0f
+# bx <- 0
+bb 00 00
+# *ds:bx <- ax
+89 07  # 00b/mod/indirect 000b/reg/ax 111b/rm/bx
+
+e9 fd ff  # loop forever
+
+# padding to 512 bytes
+   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00
+
+55 aa  # final 2 bytes: boot sector marker
+
+# vim:ft=subx