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