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-code-point-on-real-screen c: code-point, x: int, y: int, color: int, background-color: int -> _/eax: int
  4 sig overlay-code-point-on-real-screen c: code-point, x: int, y: int, color: int, background-color: int -> _/eax: int
  5 sig draw-code-point-on-screen-array screen-data: (addr array byte), c: code-point, x: int, y: int, color: int, background-color: int, screen-width: int, screen-height: int -> _/eax: int
  6 sig wide-code-point? c: code-point -> _/eax: boolean
  7 sig combining-code-point? c: code-point -> _/eax: boolean
  8 sig cursor-position-on-real-screen -> _/eax: int, _/ecx: int
  9 sig set-cursor-position-on-real-screen x: int, y: int
 10 sig draw-cursor-on-real-screen c: code-point
 11 sig color-rgb color: int -> _/ecx: int, _/edx: int, _/ebx: int
 12 
 13 # timer
 14 sig timer-counter -> _/eax: int
 15 
 16 # keyboard
 17 sig read-key kbd: (addr keyboard) -> _/eax: byte
 18 
 19 # disk
 20 sig read-ata-disk disk: (addr disk), lba: int, n: int, out: (addr stream byte)
 21 sig write-ata-disk disk: (addr disk), lba: int, n: int, out: (addr stream byte)
 22 
 23 # mouse
 24 sig read-mouse-event -> _/eax: int, _/ecx: int
 25 
 26 # tests
 27 sig count-test-failure
 28 sig num-test-failures -> _/eax: int
 29 sig running-tests? -> _/eax: boolean
 30 
 31 sig string-equal? s: (addr array byte), benchmark: (addr array byte) -> _/eax: boolean
 32 sig string-starts-with? s: (addr array byte), benchmark: (addr array byte) -> _/eax: boolean
 33 sig check-strings-equal s: (addr array byte), expected: (addr array byte), msg: (addr array byte)
 34 
 35 # debugging
 36 sig check-stack
 37 sig show-stack-state
 38 sig debug-print x: (addr array byte), fg: int, bg: int
 39 sig debug-print? -> _/eax: boolean
 40 sig turn-on-debug-print
 41 sig turn-off-debug-print
 42 sig abort e: (addr array byte)
 43 sig dump-call-stack
 44 sig heap-bound -> _/eax: int
 45 
 46 sig count-event
 47 sig count-of-events -> _/eax: int
 48 
 49 # streams
 50 sig clear-stream f: (addr stream _)
 51 sig rewind-stream f: (addr stream _)
 52 sig stream-data-equal? f: (addr stream byte), s: (addr array byte) -> _/eax: boolean
 53 sig streams-data-equal? a: (addr stream byte), b: (addr stream byte) -> _/eax: boolean
 54 sig check-stream-equal f: (addr stream byte), s: (addr array byte), msg: (addr array byte)
 55 sig check-streams-data-equal s: (addr stream _), expected: (addr stream _), msg: (addr array byte)
 56 sig next-stream-line-equal? f: (addr stream byte), s: (addr array byte) -> _/eax: boolean
 57 sig check-next-stream-line-equal f: (addr stream byte), s: (addr array byte), msg: (addr array byte)
 58 sig write f: (addr stream byte), s: (addr array byte)
 59 sig try-write f: (addr stream byte), s: (addr array byte) -> _/eax: boolean
 60 # probably a bad idea; I definitely want to discourage its use for streams of non-bytes
 61 sig stream-size f: (addr stream byte) -> _/eax: int
 62 sig space-remaining-in-stream f: (addr stream byte) -> _/eax: int
 63 sig write-stream f: (addr stream byte), s: (addr stream byte)
 64 sig write-stream-immutable f: (addr stream byte), s: (addr stream byte)
 65 sig read-byte s: (addr stream byte) -> _/eax: byte
 66 sig peek-byte s: (addr stream byte) -> _/eax: byte
 67 sig append-byte f: (addr stream byte), n: int  # really just a byte, but I want to pass in literal numbers
 68 sig undo-append-byte f: (addr stream byte)  # take most recent append back out
 69 #sig to-hex-char in/eax: int -> out/eax: int
 70 sig append-byte-hex f: (addr stream byte), n: int  # really just a byte, but I want to pass in literal numbers
 71 sig write-int32-hex f: (addr stream byte), n: int
 72 sig write-int32-hex-bits f: (addr stream byte), n: int, bits: int
 73 sig hex-int? in: (addr slice) -> _/eax: boolean
 74 sig parse-hex-int in: (addr array byte) -> _/eax: int
 75 sig parse-hex-int-from-slice in: (addr slice) -> _/eax: int
 76 #sig parse-hex-int-helper start: (addr byte), end: (addr byte) -> _/eax: int
 77 sig hex-digit? c: byte -> _/eax: boolean
 78 #sig from-hex-char in/eax: byte -> out/eax: nibble
 79 sig parse-decimal-int in: (addr array byte) -> _/eax: int
 80 sig parse-decimal-int-from-slice in: (addr slice) -> _/eax: int
 81 sig parse-decimal-int-from-stream in: (addr stream byte) -> _/eax: int
 82 #sig parse-decimal-int-helper start: (addr byte), end: (addr byte) -> _/eax: int
 83 sig decimal-size n: int -> _/eax: int
 84 #sig allocate ad: (addr allocation-descriptor), n: int, out: (addr handle _)
 85 #sig allocate-raw ad: (addr allocation-descriptor), n: int, out: (addr handle _)
 86 sig lookup h: (handle _T) -> _/eax: (addr _T)
 87 sig handle-equal? a: (handle _T), b: (handle _T) -> _/eax: boolean
 88 sig copy-handle src: (handle _T), dest: (addr handle _T)
 89 #sig allocate-region ad: (addr allocation-descriptor), n: int, out: (addr handle allocation-descriptor)
 90 #sig allocate-array ad: (addr allocation-descriptor), n: int, out: (addr handle _)
 91 sig copy-array ad: (addr allocation-descriptor), src: (addr array _T), out: (addr handle array _T)
 92 #sig zero-out start: (addr byte), size: int
 93 sig slice-empty? s: (addr slice) -> _/eax: boolean
 94 sig slice-equal? s: (addr slice), p: (addr array byte) -> _/eax: boolean
 95 sig slice-starts-with? s: (addr slice), head: (addr array byte) -> _/eax: boolean
 96 sig write-slice out: (addr stream byte), s: (addr slice)
 97 # bad name alert
 98 sig slice-to-string ad: (addr allocation-descriptor), in: (addr slice), out: (addr handle array byte)
 99 sig write-int32-decimal out: (addr stream byte), n: int
100 sig decimal-digit? c: code-point-utf8 -> _/eax: boolean
101 sig to-decimal-digit in: code-point-utf8 -> _/eax: int
102 # bad name alert
103 # next-word really tokenizes
104 # next-raw-word really reads whitespace-separated words
105 sig next-word line: (addr stream byte), out: (addr slice)  # merges '#' comments into a single word
106 sig next-raw-word line: (addr stream byte), out: (addr slice)  # does not merge '#' comments
107 sig skip-chars-matching in: (addr stream byte), delimiter: byte
108 sig skip-chars-matching-whitespace in: (addr stream byte)
109 sig skip-chars-not-matching in: (addr stream byte), delimiter: byte
110 sig skip-chars-not-matching-whitespace in: (addr stream byte)
111 sig stream-empty? s: (addr stream _) -> _/eax: boolean
112 sig stream-full? s: (addr stream _) -> _/eax: boolean
113 sig stream-to-array in: (addr stream _), out: (addr handle array _)
114 sig unquote-stream-to-array in: (addr stream _), out: (addr handle array _)
115 sig stream-first s: (addr stream byte) -> _/eax: byte
116 sig stream-final s: (addr stream byte) -> _/eax: byte
117 
118 #sig copy-bytes src: (addr byte), dest: (addr byte), n: int
119 sig copy-array-object src: (addr array _), dest-ah: (addr handle array _)
120 sig array-equal? a: (addr array int), b: (addr array int) -> _/eax: boolean
121 sig parse-array-of-ints s: (addr array byte), out: (addr handle array int)
122 sig parse-array-of-decimal-ints s: (addr array byte), out: (addr handle array int)
123 sig check-array-equal a: (addr array int), expected: (addr array byte), msg: (addr array byte)
124 
125 sig integer-divide a: int, b: int -> _/eax: int, _/edx: int