about summary refs log tree commit diff stats
path: root/html/408float.mu.html
blob: c5520cadddd1403fd67e3bb4e80f32d2082384e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mu - 408float.mu</title>
<meta name="Generator" content="Vim/8.2">
<meta name="plugin-version" content="vim8.1_v2">
<meta name="syntax" content="none">
<meta name="settings" content="number_lines,use_css,pre_wrap,no_foldcolumn,expand_tabs,line_ids,prevent_copy=,use_input_for_pc=fallback">
<meta name="colorscheme" content="minimal-light">
<style>
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #ffffd7; }
body { font-size:12pt; font-family: monospace; color: #000000; background-color: #ffffd7; }
a { color:inherit; }
* { font-size:12pt; font-size: 1em; }
.PreProc { color: #c000c0; }
.LineNr { }
.muRegEdi { color: #00af00; }
.Constant { color: #008787; }
.muFunction { color: #af5f00; text-decoration: underline; }
.Delimiter { color: #c000c0; }
.muComment { color: #005faf; }
.Special { color: #ff6060; }
-->
</style>

<script>
<!--

/* 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/408float.mu'>https://github.com/akkartik/mu/blob/main/408float.mu</a>
<pre id='vimCodeElement'>
<span id="L1" class="LineNr"> 1 </span><span class="muComment"># Some quick-n-dirty ways to create floats.</span>
<span id="L2" class="LineNr"> 2 </span>
<span id="L3" class="LineNr"> 3 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='408float.mu.html#L3'>fill-in-rational</a></span> _out: (addr float), nr: int, dr: int <span class="Delimiter">{</span>
<span id="L4" class="LineNr"> 4 </span>  <span class="PreProc">var</span> out/<span class="muRegEdi">edi</span>: (addr float) <span class="Special">&lt;-</span> copy _out
<span id="L5" class="LineNr"> 5 </span>  <span class="PreProc">var</span> result/<span class="Constant">xmm0</span>: float <span class="Special">&lt;-</span> convert nr
<span id="L6" class="LineNr"> 6 </span>  <span class="PreProc">var</span> divisor/<span class="Constant">xmm1</span>: float <span class="Special">&lt;-</span> convert dr
<span id="L7" class="LineNr"> 7 </span>  result <span class="Special">&lt;-</span> divide divisor
<span id="L8" class="LineNr"> 8 </span>  copy-to *out, result
<span id="L9" class="LineNr"> 9 </span><span class="Delimiter">}</span>
<span id="L10" class="LineNr">10 </span>
<span id="L11" class="LineNr">11 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='408float.mu.html#L11'>fill-in-sqrt</a></span> _out: (addr float), n: int <span class="Delimiter">{</span>
<span id="L12" class="LineNr">12 </span>  <span class="PreProc">var</span> out/<span class="muRegEdi">edi</span>: (addr float) <span class="Special">&lt;-</span> copy _out
<span id="L13" class="LineNr">13 </span>  <span class="PreProc">var</span> result/<span class="Constant">xmm0</span>: float <span class="Special">&lt;-</span> convert n
<span id="L14" class="LineNr">14 </span>  result <span class="Special">&lt;-</span> square-root result
<span id="L15" class="LineNr">15 </span>  copy-to *out, result
<span id="L16" class="LineNr">16 </span><span class="Delimiter">}</span>
<span id="L17" class="LineNr">17 </span>
<span id="L18" class="LineNr">18 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='408float.mu.html#L18'>rational</a></span> nr: int, dr: int<span class="PreProc"> -&gt; </span>_/<span class="Constant">xmm0</span>: float <span class="Delimiter">{</span>
<span id="L19" class="LineNr">19 </span>  <span class="PreProc">var</span> result/<span class="Constant">xmm0</span>: float <span class="Special">&lt;-</span> convert nr
<span id="L20" class="LineNr">20 </span>  <span class="PreProc">var</span> divisor/<span class="Constant">xmm1</span>: float <span class="Special">&lt;-</span> convert dr
<span id="L21" class="LineNr">21 </span>  result <span class="Special">&lt;-</span> divide divisor
<span id="L22" class="LineNr">22 </span>  <span class="PreProc">return</span> result
<span id="L23" class="LineNr">23 </span><span class="Delimiter">}</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->
class="w"> s: (addr array byte) -> _/eax: boolean sig check-next-stream-line-equal f: (addr stream byte), s: (addr array byte), msg: (addr array byte) sig tailor-exit-descriptor ed: (addr exit-descriptor), nbytes: int sig stop ed: (addr exit-descriptor), value: int #sig read f: fd or (addr stream byte), s: (addr stream byte) -> _/eax: int sig read-byte-buffered f: (addr buffered-file) -> _/eax: byte sig read-byte s: (addr stream byte) -> _/eax: byte #sig write-stream f: fd or (addr stream byte), s: (addr stream byte) #sig error ed: (addr exit-descriptor), out: fd or (addr stream byte), msg: (addr array byte) sig write-byte-buffered f: (addr buffered-file), n: int sig flush f: (addr buffered-file) sig append-byte f: (addr stream byte), n: int sig write-buffered f: (addr buffered-file), msg: (addr array byte) #sig to-hex-char in/eax: int -> out/eax: int sig append-byte-hex f: (addr stream byte), n: int sig write-byte-hex-buffered f: (addr buffered-file), n: int sig write-int32-hex f: (addr stream byte), n: int sig write-int32-hex-bits f: (addr stream byte), n: int, bits: int sig write-int32-hex-buffered f: (addr buffered-file), n: int sig write-int32-hex-bits-buffered f: (addr buffered-file), n: int, bits: int sig hex-int? in: (addr slice) -> _/eax: boolean sig parse-hex-int in: (addr array byte) -> _/eax: int sig parse-hex-int-from-slice in: (addr slice) -> _/eax: int #sig parse-hex-int-helper start: (addr byte), end: (addr byte) -> _/eax: int sig hex-digit? c: byte -> _/eax: boolean #sig from-hex-char in/eax: byte -> out/eax: nibble sig parse-decimal-int in: (addr array byte) -> _/eax: int sig parse-decimal-int-from-slice in: (addr slice) -> _/eax: int sig parse-decimal-int-from-stream in: (addr stream byte) -> _/eax: int #sig parse-decimal-int-helper start: (addr byte), end: (addr byte) -> _/eax: int sig decimal-size n: int -> _/eax: int sig error-byte ed: (addr exit-descriptor), out: (addr buffered-file), msg: (addr array byte), n: byte #sig allocate ad: (addr allocation-descriptor), n: int, out: (addr handle _) #sig allocate-raw ad: (addr allocation-descriptor), n: int, out: (addr handle _) sig lookup h: (handle _T) -> _/eax: (addr _T) sig handle-equal? a: (handle _T), b: (handle _T) -> _/eax: boolean sig copy-handle src: (handle _T), dest: (addr handle _T) #sig allocate-region ad: (addr allocation-descriptor), n: int, out: (addr handle allocation-descriptor) #sig allocate-array ad: (addr allocation-descriptor), n: int, out: (addr handle _) sig copy-array ad: (addr allocation-descriptor), src: (addr array _T), out: (addr handle array _T) #sig zero-out start: (addr byte), size: int #sig new-stream ad: (addr allocation-descriptor), length: int, elemsize: int, out: (addr handle stream _) sig read-line-buffered f: (addr buffered-file), s: (addr stream byte) sig read-line f: (addr stream byte), s: (addr stream byte) sig slice-empty? s: (addr slice) -> _/eax: boolean sig slice-equal? s: (addr slice), p: (addr array byte) -> _/eax: boolean sig slice-starts-with? s: (addr slice), head: (addr array byte) -> _/eax: boolean sig write-slice out: (addr stream byte), s: (addr slice) sig write-slice-buffered out: (addr buffered-file), s: (addr slice) # bad name alert sig slice-to-string ad: (addr allocation-descriptor), in: (addr slice), out: (addr handle array byte) sig _slice-to-string in: (addr slice), out: (addr handle array byte) sig next-token in: (addr stream byte), delimiter: byte, out: (addr slice) sig next-token-from-slice start: (addr byte), end: (addr byte), delimiter: byte, out: (addr slice) sig skip-chars-matching in: (addr stream byte), delimiter: byte sig skip-chars-matching-whitespace in: (addr stream byte) sig skip-chars-not-matching in: (addr stream byte), delimiter: byte sig skip-chars-not-matching-whitespace in: (addr stream byte) #sig skip-chars-matching-in-slice curr: (addr byte), end: (addr byte), delimiter: byte -> _/eax: (addr byte) #sig skip-chars-matching-whitespace-in-slice curr: (addr byte), end: (addr byte) -> _/eax: (addr byte) #sig skip-chars-not-matching-in-slice curr: (addr byte), end: (addr byte), delimiter: byte -> _/eax: (addr byte) #sig skip-chars-not-matching-whitespace-in-slice curr: (addr byte), end: (addr byte) -> _/eax: (addr byte) sig skip-string line: (addr stream byte) #sig skip-string-in-slice curr: (addr byte), end: (addr byte) -> _/eax: (addr byte) sig skip-until-close-paren line: (addr stream byte) #sig skip-until-close-paren-in-slice curr: (addr byte), end: (addr byte) -> _/eax: (addr byte) sig write-stream-data f: (addr buffered-file), s: (addr stream byte) sig write-int32-decimal out: (addr stream byte), n: int sig decimal-digit? c: grapheme -> _/eax: boolean sig to-decimal-digit in: grapheme -> _/eax: int # bad name alert # next-word really tokenizes # next-raw-word really reads whitespace-separated words sig next-word line: (addr stream byte), out: (addr slice) # skips '#' comments sig next-raw-word line: (addr stream byte), out: (addr slice) # does not skip '#' comments sig has-metadata? word: (addr slice), s: (addr string) -> _/eax: boolean sig valid-name? in: (addr slice) -> _/eax: boolean sig label? word: (addr slice) -> _/eax: boolean sig emit-hex out: (addr buffered-file), n: int, width: int sig emit out: (addr buffered-file), word: (addr slice), width: int #sig get table: (addr stream {(handle array byte), T}), key: (addr array byte), row-size: int, abort-message-prefix: (addr array byte) -> _/eax: (addr T) #sig get-slice table: (addr stream {(handle array byte), T}), key: (addr slice), row-size: int, abort-message-prefix: (addr array byte) -> _/eax: (addr T) #sig get-or-insert table: (addr stream {(handle array byte), T}), key: (addr array byte), row-size: int, ad: (addr allocation-descriptor) -> _/eax: (addr T) #sig get-or-insert-handle table: (addr stream {(handle array byte), T}), key: (handle array byte), row-size: int -> _/eax: (addr T) #sig get-or-insert-slice table: (addr stream {(handle array byte), T}), key: (addr slice), row-size: int, ad: (addr allocation-descriptor) -> _/eax: (addr T) #sig get-or-stop table: (addr stream {(handle array byte), T}), key: (addr array byte), row-size: int #sig get-slice-or-stop table: (addr stream {(handle array byte), _}), key: (addr slice), row-size: int #sig maybe-get table: (addr stream {(handle array byte), T}), key: (addr array byte), row-size: int -> _/eax: (addr T) #sig maybe-get-slice table: (addr stream {(handle array byte), T}), key: (addr slice), row-size: int -> _/eax: (addr T) sig slurp f: (addr buffered-file), s: (addr stream byte) sig compute-width word: (addr array byte) -> _/eax: int sig compute-width-of-slice s: (addr slice) -> _/eax: int sig emit-hex-array out: (addr buffered-file), arr: (addr array byte) sig next-word-or-string line: (addr stream byte), out: (addr slice) sig write-int out: (addr stream byte), n: int #sig clear-stack s: (addr stack) #sig push s: (addr stack), n: int #sig pop s: (addr stack) -> _/eax: int #sig top s: (addr stack) -> _/eax: int sig array-equal? a: (addr array int), b: (addr array int) -> _/eax: boolean sig parse-array-of-ints s: (addr array byte), out: (addr handle array int) sig parse-array-of-decimal-ints s: (addr array byte), out: (addr handle array int) sig check-array-equal a: (addr array int), expected: (addr string), msg: (addr string) #sig push-n-zero-bytes n: int sig kernel-string-to-string ad: (addr allocation-descriptor), in: (addr kernel-string), out: (addr handle array byte) sig kernel-string-length in: (addr kernel-string) -> _/eax: int sig enable-screen-grid-mode sig enable-screen-type-mode sig real-screen-size -> _/eax: int, _/ecx: int sig clear-real-screen sig move-cursor-on-real-screen row: int, column: int sig print-string-to-real-screen s: (addr array byte) sig print-slice-to-real-screen s: (addr slice) sig print-stream-to-real-screen s: (addr stream byte) sig print-grapheme-to-real-screen c: grapheme sig print-int32-hex-to-real-screen n: int sig print-int32-hex-bits-to-real-screen n: int, bits: int sig print-int32-decimal-to-real-screen n: int sig write-int32-decimal-buffered f: (addr buffered-file), n: int sig reset-formatting-on-real-screen sig start-color-on-real-screen fg: int, bg: int sig start-bold-on-real-screen sig start-underline-on-real-screen sig start-reverse-video-on-real-screen sig start-blinking-on-real-screen sig hide-cursor-on-real-screen sig show-cursor-on-real-screen sig enable-keyboard-immediate-mode sig enable-keyboard-type-mode sig read-key-from-real-keyboard -> _/eax: grapheme sig read-line-from-real-keyboard out: (addr stream byte) sig open filename: (addr array byte), write?: boolean, out: (addr handle buffered-file) sig populate-buffered-file-containing contents: (addr array byte), out: (addr handle buffered-file) sig new-buffered-file out: (addr handle buffered-file) #sig size in: (addr array _) -> _/eax: int sig stream-empty? s: (addr stream _) -> _/eax: boolean sig stream-full? s: (addr stream _) -> _/eax: boolean sig stream-to-array in: (addr stream _), out: (addr handle array _) sig unquote-stream-to-array in: (addr stream _), out: (addr handle array _) sig stream-first s: (addr stream byte) -> _/eax: byte sig stream-final s: (addr stream byte) -> _/eax: byte #sig copy-bytes src: (addr byte), dest: (addr byte), n: int sig copy-array-object src: (addr array _), dest-ah: (addr handle array _) sig copy-file src: (addr buffered-file), dest-ah: (addr handle buffered-file), filename: (addr array byte) sig integer-divide a: int, b: int -> _/eax: int, _/edx: int