From 3d1c4216ede8c628558c9fe700fb2be1aa08b473 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 2 Nov 2020 21:24:53 -0800 Subject: 7162 --- html/apps/tile/int-stack.mu.html | 68 ++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 37 deletions(-) (limited to 'html/apps/tile/int-stack.mu.html') diff --git a/html/apps/tile/int-stack.mu.html b/html/apps/tile/int-stack.mu.html index 5298b78d..d1210ea1 100644 --- a/html/apps/tile/int-stack.mu.html +++ b/html/apps/tile/int-stack.mu.html @@ -87,44 +87,38 @@ if ('onhashchange' in window) { 29 add-to *top-addr, 1 30 } 31 -32 fn pop-int-stack _self: (addr int-stack) -> val/eax: int { -33 $pop-int-stack:body: { -34 var self/esi: (addr int-stack) <- copy _self -35 var top-addr/ecx: (addr int) <- get self, top -36 { -37 compare *top-addr, 0 -38 break-if-> -39 val <- copy 0 -40 break $pop-int-stack:body -41 } -42 subtract-from *top-addr, 1 -43 var data-ah/edx: (addr handle array int) <- get self, data -44 var data/eax: (addr array int) <- lookup *data-ah -45 var top/edx: int <- copy *top-addr -46 var result-addr/eax: (addr int) <- index data, top -47 val <- copy *result-addr -48 } -49 } -50 -51 fn int-stack-empty? _self: (addr int-stack) -> result/eax: boolean { -52 $int-stack-empty?:body: { -53 var self/esi: (addr int-stack) <- copy _self -54 var top-addr/eax: (addr int) <- get self, top -55 compare *top-addr, 0 -56 { -57 break-if-!= -58 result <- copy 1 # true -59 break $int-stack-empty?:body -60 } -61 result <- copy 0 # false -62 } +32 fn pop-int-stack _self: (addr int-stack) -> _/eax: int { +33 var self/esi: (addr int-stack) <- copy _self +34 var top-addr/ecx: (addr int) <- get self, top +35 { +36 compare *top-addr, 0 +37 break-if-> +38 return 0 +39 } +40 subtract-from *top-addr, 1 +41 var data-ah/edx: (addr handle array int) <- get self, data +42 var data/eax: (addr array int) <- lookup *data-ah +43 var top/edx: int <- copy *top-addr +44 var result-addr/eax: (addr int) <- index data, top +45 return *result-addr +46 } +47 +48 fn int-stack-empty? _self: (addr int-stack) -> _/eax: boolean { +49 var self/esi: (addr int-stack) <- copy _self +50 var top-addr/eax: (addr int) <- get self, top +51 compare *top-addr, 0 +52 { +53 break-if-!= +54 return 1 # true +55 } +56 return 0 # false +57 } +58 +59 fn int-stack-length _self: (addr int-stack) -> _/eax: int { +60 var self/esi: (addr int-stack) <- copy _self +61 var top-addr/eax: (addr int) <- get self, top +62 return *top-addr 63 } -64 -65 fn int-stack-length _self: (addr int-stack) -> result/eax: int { -66 var self/esi: (addr int-stack) <- copy _self -67 var top-addr/eax: (addr int) <- get self, top -68 result <- copy *top-addr -69 } -- cgit 1.4.1-2-gfad0