From 3350c34a74844e21ea69077e01efff3bae64bdcd Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 23 Mar 2021 17:31:08 -0700 Subject: . --- html/ex3.mu.html | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 html/ex3.mu.html (limited to 'html/ex3.mu.html') diff --git a/html/ex3.mu.html b/html/ex3.mu.html new file mode 100644 index 00000000..0c2dbe62 --- /dev/null +++ b/html/ex3.mu.html @@ -0,0 +1,93 @@ + + + + +Mu - ex3.mu + + + + + + + + + + +https://github.com/akkartik/mu/blob/main/ex3.mu +
+ 1 # Draw pixels in response to keyboard events, starting from the top-left
+ 2 # and in raster order.
+ 3 #
+ 4 # To build a disk image:
+ 5 #   ./translate ex3.mu             # emits disk.img
+ 6 # To run:
+ 7 #   qemu-system-i386 disk.img
+ 8 # Or:
+ 9 #   bochs -f bochsrc               # bochsrc loads disk.img
+10 #
+11 # Expected output: a new green pixel starting from the top left corner of the
+12 # screen every time you press a key (letter or digit)
+13 
+14 fn main {
+15   var x/ecx: int <- copy 0
+16   var y/edx: int <- copy 0
+17   {
+18     var key/eax: byte <- read-key 0/keyboard
+19     compare key, 0
+20     loop-if-=  # busy wait
+21     pixel-on-real-screen x, y, 0x31/green
+22     x <- increment
+23     compare x, 0x400/screen-width=1024
+24     {
+25       break-if-<
+26       y <- increment
+27       x <- copy 0
+28     }
+29     loop
+30   }
+31 }
+
+ + + -- cgit 1.4.1-2-gfad0