about summary refs log tree commit diff stats
path: root/baremetal/mu-init.subx
blob: b9479101cd3a8e1e433efdec1e8a189da4d9894f (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
# Initialize the minimal runtime for Mu programs.
#
# See translate_mu_baremetal for how this file is used.
#
# Mu baremetal programs start at a function called 'main' without inouts or outputs.

== code

# initialize stack
bd/copy-to-ebp 0/imm32
#? (test-run-move-cursor-into-trace)
# always first run tests
(run-tests)
(num-test-failures)  # => eax
# call main if tests all passed
{
  3d/compare-eax-and 0/imm32
  75/jump-if-!= break/disp8
  (clear-real-screen)
  c7 0/subop/copy *Real-screen-cursor-x 0/imm32
  c7 0/subop/copy *Real-screen-cursor-y 0/imm32
  (main)
}

# hang indefinitely
{
  eb/jump loop/disp8
}