about summary refs log tree commit diff stats
path: root/subx.md
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-03-07 21:05:45 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-03-07 21:05:45 -0800
commitde7713d97470528ee47031f64446d45555ee7a10 (patch)
treec8c1e0ad7ca220d062c544cbb673c80c7934a83f /subx.md
parent1a1a1671edd8d27cdd6229c08e6b40a202d85740 (diff)
downloadmu-de7713d97470528ee47031f64446d45555ee7a10.tar.gz
7867
Diffstat (limited to 'subx.md')
0 files changed, 0 insertions, 0 deletions
5f76398bc4447584b'>be87d723 ^
7bf8adb8 ^
be87d723 ^


1a43d12b ^
be87d723 ^

74f1512f ^
be87d723 ^
74f1512f ^
be87d723 ^







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31



                                                                        
                                                   
         
                             
     
                                                           



                                                                             
                                                                                  


                          
                                          

                          
                                         
                  
                                      







                    
# Draw pixels in response to keyboard events, starting from the top-left
# and in raster order.
#
# To build a disk image:
#   ./translate ex3.mu             # emits code.img
# To run:
#   qemu-system-i386 code.img
# Or:
#   bochs -f bochsrc               # bochsrc loads code.img
#
# Expected output: a new green pixel starting from the top left corner of the
# screen every time you press a key (letter or digit)

fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
  var x/ecx: int <- copy 0
  var y/edx: int <- copy 0
  {
    var key/eax: byte <- read-key keyboard
    compare key, 0
    loop-if-=  # busy wait
    pixel-on-real-screen x, y, 0x31/green
    x <- increment
    compare x, 0x400/screen-width=1024
    {
      break-if-<
      y <- increment
      x <- copy 0
    }
    loop
  }
}