https://github.com/akkartik/mu/blob/main/400.mu
 1 # screen
 2 sig pixel-on-real-screen x: int, y: int, color: int
 3 sig draw-grapheme-on-real-screen g: grapheme, x: int, y: int, color: int, background-color: int
 4 sig cursor-position-on-real-screen -> _/eax: int, _/ecx: int
 5 sig set-cursor-position-on-real-screen x: int, y: int
 6 sig draw-cursor-on-real-screen g: grapheme
 7 
 8 # keyboard
 9 sig read-key kbd: (addr keyboard) -> _/eax: byte
10 
11 # disk
12 sig load-sectors disk: (addr disk), lba: int, n: int, out: (addr stream byte)
13 sig store-sectors disk: (addr disk), lba: int, n: int, out: (addr stream byte)
14 
15 # mouse
16 sig read-mouse-event -> _/eax: int, _/ecx: int
17 
18 # tests
19 sig count-test-failure
20 sig num-test-failures -> _/eax: int
21 
22 sig string-equal? s: (addr array byte), benchmark: (addr array byte) -> _/eax: boolean
23 sig string-starts-with? s: (addr array byte), benchmark: (addr array byte) -> _/eax: boolean
24 sig check-strings-equal s: (addr array byte), expected: (addr array byte), msg: (addr array byte)
25 
26 # debugging
27 sig check-stack
28 sig show-stack-state
29 sig debug-print x: (addr array byte), fg: int, bg: int
30 
31 # streams
32 sig clear-stream f: (addr stream _)
33 sig rewind-stream f: (addr stream _)
34 sig stream-data-equal? f: (addr stream byte), s: (addr array byte) -> _/eax: boolean
35 sig check-stream-equal f: (addr stream byte), s: (addr array byte), msg: (addr array byte)
36 sig next-stream-line-equal? f: (addr stream byte), s: (addr array byte) -> _/eax: boolean
37 sig check-next-stream-line-equal f: (addr stream byte), s: (addr array byte), msg: (addr array byte)
38 sig write f: (addr stream byte), s: (addr array byte)
39 sig write-stream f: (addr stream byte), s: (addr stream byte)
40 sig read-byte s: (addr stream byte) -> _/eax: byte
41 sig append-byte f: (addr stream byte), n: int  # really just a byte, but I want to pass in literal numbers
42 #sig to-hex-char in/eax: int -> out/eax: int
43 sig append-byte-hex f: (addr stream byte), n: int  # really just a byte, but I want to pass in literal numbers
44 sig write-int32-hex f: (addr stream byte), n: int
45 sig write-int32-hex-bits f: (addr stream byte), n: int, bits: int
46 sig hex-int? in: (addr slice) -> _/eax: boolean
47 sig parse-hex-int in: (addr array byte) -> _/eax: int
48 sig parse-hex-int-from-slice in: (addr slice) -> _/eax: int
49 #sig parse-hex-int-helper start: (addr byte), end: (addr byte) -> _/eax: int
50 sig hex-digit? c: byte -> _/eax: boolean
51 #sig from-hex-char in/eax: byte -> out/eax: nibble
52 sig parse-decimal-int in: (addr array byte) -> _/eax: int
53 sig parse-decimal-int-from-slice in: (addr slice) -> _/eax: int
54 sig parse-decimal-int-from-stream in: (addr stream byte) -> _/eax: int
55 #sig parse-decimal-int-helper start: (addr byte), end: (addr byte) -> _/eax: int
56 sig decimal-size n: int -> _/eax: int
57 #sig allocate ad: (addr allocation-descriptor), n: int, out: (addr handle _)
58 #sig allocate-raw ad: (addr allocation-descriptor), n: int, out: (addr handle _)
59 sig lookup h: (handle _T) -> _/eax: (addr _T)
60 sig handle-equal? a: (handle _T), b: (handle _T) -> _/eax: boolean
61 sig copy-handle src: (handle _T), dest: (addr handle _T)
62 #sig allocate-region ad: (addr allocation-descriptor), n: int, out: (addr handle allocation-descriptor)
63 #sig allocate-array ad: (addr allocation-descriptor), n: int, out: (addr handle _)
64 sig copy-array ad: (addr allocation-descriptor), src: (addr array _T), out: (addr handle array _T)
65 #sig zero-out start: (addr byte), size: int
66 sig slice-empty? s: (addr slice) -> _/eax: boolean
67 sig slice-equal? s: (addr slice), p: (addr array byte) -> _/eax: boolean
68 sig slice-starts-with? s: (addr slice), head: (addr array byte) -> _/eax: boolean
69 sig write-slice out: (addr stream byte), s: (addr slice)
70 # bad name alert
71 sig slice-to-string ad: (addr allocation-descriptor), in: (addr slice), out: (addr handle array byte)
72 sig write-int32-decimal out: (addr stream byte), n: int
73 sig decimal-digit? c: grapheme -> _/eax: boolean
74 sig to-decimal-digit in: grapheme -> _/eax: int
75 # bad name alert
76 # next-word really tokenizes
77 # next-raw-word really reads whitespace-separated words
78 sig next-word line: (addr stream byte), out: (addr slice)  # skips '#' comments
79 sig next-raw-word line: (addr stream byte), out: (addr slice)  # does not skip '#' comments
80 sig stream-empty? s: (addr stream _) -> _/eax: boolean
81 sig stream-full? s: (addr stream _) -> _/eax: boolean
82 sig stream-to-array in: (addr stream _), out: (addr handle array _)
83 sig unquote-stream-to-array in: (addr stream _), out: (addr handle array _)
84 sig stream-first s: (addr stream byte) -> _/eax: byte
85 sig stream-final s: (addr stream byte) -> _/eax: byte
86 
87 #sig copy-bytes src: (addr byte), dest: (addr byte), n: int
88 sig copy-array-object src: (addr array _), dest-ah: (addr handle array _)
89 sig array-equal? a: (addr array int), b: (addr array int) -> _/eax: boolean
90 sig parse-array-of-ints s: (addr array byte), out: (addr handle array int)
91 sig parse-array-of-decimal-ints s: (addr array byte), out: (addr handle array int)
92 sig check-array-equal a: (addr array int), expected: (addr string), msg: (addr string)
93 
94 sig integer-divide a: int, b: int -> _/eax: int, _/edx: int