From b4af05394ae60a372053f48095104e2965791569 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Wed, 13 Jan 2021 19:06:34 -0800 Subject: 7511 --- html/baremetal/ex7.mu.html | 108 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 html/baremetal/ex7.mu.html (limited to 'html/baremetal/ex7.mu.html') diff --git a/html/baremetal/ex7.mu.html b/html/baremetal/ex7.mu.html new file mode 100644 index 00000000..72ba26f4 --- /dev/null +++ b/html/baremetal/ex7.mu.html @@ -0,0 +1,108 @@ + + + + +Mu - baremetal/ex7.mu + + + + + + + + + + +https://github.com/akkartik/mu/blob/main/baremetal/ex7.mu +
+ 1 # Cursor-based motions.
+ 2 #
+ 3 # To build a disk image:
+ 4 #   ./translate_mu_baremetal baremetal/ex7.mu     # emits disk.img
+ 5 # To run:
+ 6 #   qemu-system-i386 disk.img
+ 7 # Or:
+ 8 #   bochs -f baremetal/boot.bochsrc               # boot.bochsrc loads disk.img
+ 9 #
+10 # Expected output: an interactive game a bit like "snakes". Try pressing h, j,
+11 # k, l.
+12 
+13 fn main {
+14   {
+15     var key/eax: byte <- read-key 0
+16     {
+17       compare key, 0x68  # 'h'
+18       break-if-!=
+19       var g/eax: grapheme <- copy 0x2d  # '-'
+20       draw-grapheme-at-cursor 0, g, 0x31
+21       cursor-left 0
+22     }
+23     {
+24       compare key, 0x6a  # 'j'
+25       break-if-!=
+26       var g/eax: grapheme <- copy 0x7c  # '|'
+27       draw-grapheme-at-cursor 0, g, 0x31
+28       cursor-down 0
+29     }
+30     {
+31       compare key, 0x6b  # 'k'
+32       break-if-!=
+33       var g/eax: grapheme <- copy 0x7c  # '|'
+34       draw-grapheme-at-cursor 0, g, 0x31
+35       cursor-up 0
+36     }
+37     {
+38       compare key, 0x6c  # 'l'
+39       break-if-!=
+40       var g/eax: grapheme <- copy 0x2d  # '-'
+41       draw-grapheme-at-cursor 0, g, 0x31
+42       cursor-right 0
+43     }
+44     loop
+45   }
+46 }
+
+ + + -- cgit 1.4.1-2-gfad0