about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-12-26 19:13:23 -0800
committerKartik Agaram <vc@akkartik.com>2020-12-26 19:13:23 -0800
commit73728ec665e8b128b63c6c633f7c1dd7cfcae2f4 (patch)
treeb09e704fad0fb64642f7fcb9d7fbb68da0c22d83
parent4b26c93e69e13462b7397f860b4f52b12aae2897 (diff)
downloadmu-73728ec665e8b128b63c6c633f7c1dd7cfcae2f4.tar.gz
7412 - drawing pixels to screen
This works, but colors are unexpected. 0xff isn't white. Lots of colors
are black. Perhaps I need to initialize a palette.
-rw-r--r--020byte_addressing.cc2
-rw-r--r--baremetal/ex1.hex2
-rw-r--r--baremetal/ex2.hex29
-rw-r--r--subx_opcodes2
4 files changed, 32 insertions, 3 deletions
diff --git a/020byte_addressing.cc b/020byte_addressing.cc
index 93e269e1..399e9199 100644
--- a/020byte_addressing.cc
+++ b/020byte_addressing.cc
@@ -136,7 +136,7 @@ void test_cannot_copy_byte_to_ESP_EBP_ESI_EDI() {
 //:
 
 :(before "End Initialize Op Names")
-put_new(Name, "c6", "copy imm8 to r8/m8-at-r32 (mov)");
+put_new(Name, "c6", "copy imm8 to r8/m8-at-r32 with subop 0 (mov)");
 
 :(code)
 void test_copy_imm8_to_mem_at_rm32() {
diff --git a/baremetal/ex1.hex b/baremetal/ex1.hex
index 0c605df1..8a0e5907 100644
--- a/baremetal/ex1.hex
+++ b/baremetal/ex1.hex
@@ -12,7 +12,7 @@
 # Or:
 #   bochs -f apps/boot.bochsrc  # boot.bochsrc loads disk.img
 
-# address 0x8000
+# main:  (address 0x8000)
 e9 fb ff ff ff  # jump to address 0x8000
 
 # vim:ft=subx
diff --git a/baremetal/ex2.hex b/baremetal/ex2.hex
new file mode 100644
index 00000000..d3fbec8d
--- /dev/null
+++ b/baremetal/ex2.hex
@@ -0,0 +1,29 @@
+# Test out the video mode without running afoul of video memory banking. Fill
+# just the first row with pixels.
+#
+# To run, first prepare a realistically sized disk image:
+#   dd if=/dev/zero of=disk.img count=20160  # 512-byte sectors, so 10MB
+# Load the disk image:
+#   cat baremetal/boot.hex baremetal/ex2.hex  |./bootstrap run apps/hex  > a.bin
+#   dd if=a.bin of=disk.img conv=notrunc
+# To run:
+#   qemu-system-i386 disk.img
+# Or:
+#   bochs -f apps/boot.bochsrc  # boot.bochsrc loads disk.img
+
+# main:  (address 0x8000)
+b8 ff 04 0a 00  # eax <- 0xa0000 (start of video RAM) + 0x4ff (1279 = final pixel in first row)
+# $loop:
+3d 00 00 0a 00  # compare eax with 0xa0000
+7c 06  # break if <
+# *eax <- 0xff
+c6  # copy imm8 to m8 at r32
+  00  # 00/mod/indirect 000/subop 000/eax
+  31  # imm32
+48  # decrement eax
+eb f3  # loop = -13 bytes
+
+# $break:
+e9 fb ff ff ff  # hang indefinitely
+
+# vim:ft=subx
diff --git a/subx_opcodes b/subx_opcodes
index 273c2a88..f8bdc045 100644
--- a/subx_opcodes
+++ b/subx_opcodes
@@ -80,7 +80,7 @@ Opcodes currently supported by SubX:
   bf: copy imm32 to EDI (mov)
   c1: shift rm32 by imm8 bits depending on subop (sal/sar/shl/shr)
   c3: return from most recent unfinished call (ret)
-  c6: copy imm8 to r8/m8-at-r32 (mov)
+  c6: copy imm8 to r8/m8-at-r32 with subop 0 (mov)
   c7: copy imm32 to rm32 with subop 0 (mov)
   cd: software interrupt (int)
   d3: shift rm32 by CL bits depending on subop (sal/sar/shl/shr)