clean up treeshaking support for baremetal
[mu.git] / mu-init.subx
blob8fcf84e3ece6d4d20650b60f20ae795388dceaf5
1 # Initialize the minimal runtime for Mu programs.
3 # See translate for how this file is used.
5 # Mu programs start at a function called 'main' with this signature:
6 #   fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
8 # All tests must pass first (the "power-on unit test").
10 == code
12 Entry:
13   # initialize stack
14   bd/copy-to-ebp 0/imm32
15   #
16 #?   (main 0 0 Primary-bus-secondary-drive)
17   # always first run tests
18   (run-tests)
19   (num-test-failures)  # => eax
20   # call main if tests all passed
21   {
22     3d/compare-eax-and 0/imm32
23     75/jump-if-!= break/disp8
24     c7 0/subop/copy *Running-tests? 0/imm32/false
25     (clear-real-screen)
26     c7 0/subop/copy *Real-screen-cursor-x 0/imm32
27     c7 0/subop/copy *Real-screen-cursor-y 0/imm32
28     (main 0 0 Primary-bus-secondary-drive)
29   }
31   # hang indefinitely
32   {
33     eb/jump loop/disp8
34   }