https://github.com/akkartik/mu/blob/main/linux/400.mu
  1 # The 4xx series is for primitives implemented in Mu.
  2 
  3 # Signatures for major SubX functions defined so far.
  4 
  5 # autogenerated
  6 sig run-tests
  7 
  8 # init.linux
  9 # TODO: make this OS-specific
 10 # TODO: include result type at least, even if register args are too much
 11 sig syscall_exit  # status/ebx: int
 12 sig syscall_read  # fd/ebx: int, buf/ecx: addr, size/edx: int -> nbytes-or-error/eax: int
 13 sig syscall_write  # fd/ebx: int, buf/ecx: addr, size/edx: int -> nbytes-or-error/eax: int
 14 sig syscall_open  # filename/ebx: (addr kernel-string), flags/ecx: int, dummy=0x180/edx -> fd-or-error/eax: int
 15 sig syscall_close  # fd/ebx: int -> status/eax
 16 sig syscall_creat  # filename/ebx: (addr kernel-string) -> fd-or-error/eax: int
 17 sig syscall_unlink  # filename/ebx: (addr kernel-string) -> status/eax: int
 18 sig syscall_rename  # source/ebx: (addr kernel-string), dest/ecx: (addr kernel-string) -> status/eax: int
 19 sig syscall_mmap  # arg/ebx: (addr mmap_arg_struct) -> status/eax: int
 20 sig syscall_ioctl  # fd/ebx: int, cmd/ecx: int, arg/edx: (addr _)
 21 sig syscall_nanosleep  # req/ebx: (addr timespec)
 22 sig syscall_clock_gettime  # clock/ebx: int, out/ecx: (addr timespec)
 23 
 24 # Generated using:
 25 #   grep -h '^[a-z]' [0-9]*.subx |grep -v '^test-'
 26 # Functions we don't want to make accessible from Mu are commented out.
 27 # Many functions here may not be usable yet because of missing features
 28 # (global variable support, etc.)
 29 sig check-ints-equal a: int, b: int, msg: (addr array byte)
 30 sig kernel-string-equal? s: (addr kernel-string), benchmark: (addr array byte) -> _/eax: boolean
 31 sig new-segment len: int, ad: (addr allocation-descriptor)
 32 sig string-equal? s: (addr array byte), benchmark: (addr array byte) -> _/eax: boolean
 33 sig string-starts-with? s: (addr array byte), benchmark: (addr array byte) -> _/eax: boolean
 34 sig check-strings-equal s: (addr array byte), expected: (addr array byte), msg: (addr array byte)
 35 sig clear-stream f: (addr stream _)
 36 sig rewind-stream f: (addr stream _)
 37 sig initialize-trace-stream n: int
 38 sig trace line: (addr array byte)
 39 sig check-trace-contains line: (addr string), msg: (addr string)
 40 sig check-trace-scans-to line: (addr string), msg: (addr string)
 41 sig trace-scan line: (addr array byte) -> _/eax: boolean
 42 sig next-line-matches? t: (addr stream byte), line: (addr array byte) -> _/eax: boolean
 43 sig skip-next-line t: (addr stream byte)
 44 sig clear-trace-stream
 45 sig write f: (addr stream byte), s: (addr array byte)  # writing to file descriptor not supported; use buffered-file
 46 sig stream-data-equal? f: (addr stream byte), s: (addr array byte) -> _/eax: boolean
 47 sig check-stream-equal f: (addr stream byte), s: (addr array byte), msg: (addr array byte)
 48 sig next-stream-line-equal? f: (addr stream byte), s: (addr array byte) -> _/eax: boolean
 49 sig check-next-stream-line-equal f: (addr stream byte), s: (addr array byte), msg: (addr array byte)
 50 sig tailor-exit-descriptor ed: (addr exit-descriptor), nbytes: int
 51 sig stop ed: (addr exit-descriptor), value: int
 52 #sig read f: fd or (addr stream byte), s: (addr stream byte) -> _/eax: int
 53 sig read-byte-buffered f: (addr buffered-file) -> _/eax: byte
 54 sig read-byte s: (addr stream byte) -> _/eax: byte
 55 #sig write-stream f: fd or (addr stream byte), s: (addr stream byte)
 56 #sig error ed: (addr exit-descriptor), out: fd or (addr stream byte), msg: (addr array byte)
 57 sig write-byte-buffered f: (addr buffered-file), n: int
 58 sig flush f: (addr buffered-file)
 59 sig append-byte f: (addr stream byte), n: int
 60 sig write-buffered f: (addr buffered-file), msg: (addr array byte)

<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - linux/tui.mu</title>
<meta name="Generator" content="Vim/8.1">
<meta name="plugin-version" content="vim8.1_v1">
<meta name="syntax" content="none">
<meta name="settings" content="number_lines,use_css,pre_wrap,no_foldcolumn,expand_tabs,line_ids,prevent_copy=">
<meta name="colorscheme" content="minimal-dark">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #a8a8a8; }
body { font-size:12pt; font-family: monospace; color: #000000; background-color: #a8a8a8; }
a { color:inherit; }
* { font-size:12pt; font-size: 1em; }
.PreProc { color: #c000c0; }
.Special { color: #ff6060; }
.LineNr { }
.Delimiter { color: #c000c0; }
.Constant { color: #008787; }
.muFunction { color: #af5f00; text-decoration: underline; }
.muComment { color: #005faf; }
-->
</style>

<script type='text/javascript'>
<!--

/* function to open any folds containing a jumped-to line before jumping to it */
function JumpToLine()
{
  var lineNum;
  lineNum = window.location.hash;
  lineNum = lineNum.substr(1); /* strip off '#' */

  if (lineNum.indexOf('L') == -1) {
    lineNum = 'L'+lineNum;
  }
  var lineElem = document.getElementById(lineNum);
  /* Always jump to new location even if the line was hidden inside a fold, or
   * we corrected the raw number to a line ID.
   */
  if (lineElem) {
    lineElem.scrollIntoView(true);
  }
  return true;
}
if ('onhashchange' in window) {
  window.onhashchange = JumpToLine;
}

-->
</script>
</head>
<body onload='JumpToLine();'>
<a href='https://github.com/akkartik/mu/blob/main/linux/tui.mu'>https://github.com/akkartik/mu/blob/main/linux/tui.mu</a>
<pre id='vimCodeElement'>
<span id="L1" class="LineNr"> 1 </span><span class="muComment"># Test some primitives for text-mode.</span>
<span id="L2" class="LineNr"> 2 </span><span class="muComment">#</span>
<span id="L3" class="LineNr"> 3 </span><span class="muComment"># To run:</span>
<span id="L4" class="LineNr"> 4 </span><span class="muComment">#   $ ./translate tui.mu</span>
<span id="L5" class="LineNr"> 5 </span><span class="muComment">#   $ ./a.elf</span>
<span id="L6" class="LineNr"> 6 </span>
<span id="L7" class="LineNr"> 7 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='tui.mu.html#L7'>main</a></span><span class="PreProc"> -&gt; </span>_/<span class="Constant">ebx</span>: int <span class="Delimiter">{</span>
<span id="L8" class="LineNr"> 8 </span>  <span class="PreProc">var</span> nrows/<span class="Constant">eax</span>: int <span class="Special">&lt;-</span> copy <span class="Constant">0</span>
<span id="L9" class="LineNr"> 9 </span>  <span class="PreProc">var</span> ncols/<span class="Constant">ecx</span>: int <span class="Special">&lt;-</span> copy <span class="Constant">0</span>
<span id="L10" class="LineNr">10 </span>  nrows, ncols <span class="Special">&lt;-</span> <a href='405screen.mu.html#L60'>screen-size</a> <span class="Constant">0</span>
<span id="L11" class="LineNr">11 </span>  <a href='304screen.subx.html#L6'>enable-screen-grid-mode</a>
<span id="L12" class="LineNr">12 </span>  <a href='405screen.mu.html#L109'>move-cursor</a> <span class="Constant">0</span>/screen, <span class="Constant">5</span>/row, <span class="Constant">0x22</span>/col
<span id="L13" class="LineNr">13 </span>  <a href='405screen.mu.html#L523'>start-color</a> <span class="Constant">0</span>/screen, <span class="Constant">1</span>/fg, <span class="Constant&quo