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 # Or:
 8 #   bochs -f bochsrc               # bochsrc loads code.img
 9 #
10 # Expected output: text with slowly updating colors
11 
12 fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
13   var fg/ecx: int <- copy 0
14   var prev-timer-counter/edx: int <- copy 0
15   {
16     var dummy/eax: int <- draw-text-rightward screen, "hello from baremetal Mu!", 0x10/x, 0x400/xmax, 0x10/y, fg, 0/bg
17     # wait for timer to bump
18     {
19       var curr-timer-counter/eax: int <- timer-counter
20       compare curr-timer-counter, prev-timer-counter
21       loop-if-=
22       prev-timer-counter <- copy curr-timer-counter
23     }
24     # switch color
25     fg <- increment
26     loop
27   }
28 }