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