about summary refs log tree commit diff stats
path: root/ex2.mu
blob: 148b424e24a87536b44bb0b09a7f958bc1b194f5 (plain) (blame)
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
32
33
34
35
36
37
# Test out the video mode by filling in the screen with pixels.
#
# To build a disk image:
#   ./translate ex2.mu             # emits code.img
# To run:
#   qemu-system-i386 code.img
# Or:
#   bochs -f bochsrc               # bochsrc loads code.img

fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
  var y/eax: int <- copy 0
  {
    compare y, 0x300/screen-height=768
    break-if->=
    var x/edx: int <- copy 0
    {
      compare x, 0x400/screen-width=1024
      break-if->=
      var color/ecx: int <- copy x
      color <- and 0xff
      pixel-on-real-screen x, y, color
      x <- increment
      loop
    }
    y <- increment
    loop
  }
  foo
}

fn foo {
  bar
}

fn bar {
  abort "aaa"
}