https://github.com/akkartik/mu/blob/main/apps/ex12.mu
 1 # Checking the timer.
 2 #
 3 # To build a disk image:
 4 #   ./translate apps/ex12.mu       # emits code.img
 5 # To run:
 6 #   qemu-system-i386 code.img
 7 #
 8 # Expected output: text with slowly updating colors
 9 
10 fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
11   var fg/ecx: int <- copy 0
12   var prev-timer-counter/edx: int <- copy 0
13   {
14     var dummy/eax: int <- draw-text-rightward screen, "hello from baremetal Mu!", 0x10/x, 0x400/xmax, 0x10/y, fg, 0/bg
15     # wait for timer to bump
16     {
17       var curr-timer-counter/eax: int <- timer-counter
18       compare curr-timer-counter, prev-timer-counter
19       loop-if-=
20       prev-timer-counter <- copy curr-timer-counter
21     }
22     # switch color
23     fg <- increment
24     loop
25   }
26 }