https://github.com/akkartik/mu/blob/main/linux/tile/float-stack.mu
1 type float-stack {
2 data: (handle array float)
3 top: int
4 }
5
6 fn initialize-float-stack _self: (addr float-stack), n: int {
7 var self/esi: (addr float-stack) <- copy _self
8 var d/edi: (addr handle array float) <- get self, data
9 populate d, n
10 var top/eax: (addr int) <- get self, top
11 copy-to *top, 0
12 }
13
14 fn clear-float-stack _self: (addr float-stack) {
15 var self/esi: (addr float-stack) <- copy _self
16 var top/eax: (addr int) <- get self, top
17 copy-to *top, 0
18 }
19
20 fn push-float-stack _self: (addr float-stack), _val: float {
21 var self/esi: (addr float-stack) <- copy _self
22 var top-addr/ecx: (addr int) <- get self, top
23 var data-ah/edx: (addr handle array float) <- get self, data
24 var data/eax: (addr array float) <- lookup *data-ah
25 var top/edx: int <- copy *top-addr
26 var dest-addr/edx: (addr float) <- index data, top
27 var val/xmm0: float <- copy _val
28 copy-to *dest-addr, val
29 add-to *top-addr, 1
30 }
31
32 fn pop-float-stack _self: (addr float-stack) -> _/xmm0: float {
33 var self/esi: (addr float-stack) <- copy _self
34 var top-addr/ecx: (addr int) <- get self, top
35 {
36 compare *top-addr, 0
37 break-if->
38 var zero: float
39 return zero
40 }
41 subtract-from *top-addr, 1
42 var data-ah/edx: (addr handle array float) <- get self, data
43 var data/eax: (addr array float) <- lookup *data-ah
44 var top/edx: int <- copy *top-addr
45 var result-addr/eax: (addr float) <- index data, top
46 return *result-addr
47 }
48
49 fn float-stack-empty? _self: (addr float-stack) -> _/eax: boolean {
50 var self/esi: (addr float-stack) <- copy _self
51 var top-addr/eax: (addr int) <- get self, top
52 compare *top-addr, 0
53 {
54 break-if-!=
55 return 1/true
56 }
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.hig