diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-09-19 23:26:10 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-09-19 23:26:10 -0700 |
commit | 6413032997ed0b33ee87fca915dbfd3110aeb2f9 (patch) | |
tree | 9244a08daa48d986386d2ba36262e17219338e9c /apps | |
parent | 593b95246c971bce26650141a7e3a0502c4abedb (diff) | |
download | mu-6413032997ed0b33ee87fca915dbfd3110aeb2f9.tar.gz |
6815 - tile: get actual calculations working
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tile/rpn.mu | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu index 3ca8a38f..4fec403c 100644 --- a/apps/tile/rpn.mu +++ b/apps/tile/rpn.mu @@ -88,36 +88,38 @@ fn max-stack-depth first-word: (addr word), final-word: (addr word) -> result/ed var curr-word/eax: (addr word) <- copy first-word var curr-depth/ecx: int <- copy 0 result <- copy 0 - $max-stack-depth:word-loop: { - # handle operators - { - var is-add?/eax: boolean <- word-equal? curr-word, "+" - compare is-add?, 0 - break-if-= - curr-depth <- decrement - loop $max-stack-depth:word-loop - } - { - var is-sub?/eax: boolean <- word-equal? curr-word, "-" - compare is-sub?, 0 - break-if-= - curr-depth <- decrement - loop $max-stack-depth:word-loop - } - { - var is-mul?/eax: boolean <- word-equal? curr-word, "*" - compare is-mul?, 0 - break-if-= - curr-depth <- decrement - loop $max-stack-depth:word-loop - } - # otherwise it's an int (do we need error-checking?) - curr-depth <- increment - # update max depth if necessary - { - compare curr-depth, result - break-if-<= - result <- copy curr-depth + $max-stack-depth:loop: { + $max-stack-depth:process-word: { + # handle operators + { + var is-add?/eax: boolean <- word-equal? curr-word, "+" + compare is-add?, 0 + break-if-= + curr-depth <- decrement + break $max-stack-depth:process-word + } + { + var is-sub?/eax: boolean <- word-equal? curr-word, "-" + compare is-sub?, 0 + break-if-= + curr-depth <- decrement + break $max-stack-depth:process-word + } + { + var is-mul?/eax: boolean <- word-equal? curr-word, "*" + compare is-mul?, 0 + break-if-= + curr-depth <- decrement + break $max-stack-depth:process-word + } + # otherwise it's an int (do we need error-checking?) + curr-depth <- increment + # update max depth if necessary + { + compare curr-depth, result + break-if-<= + result <- copy curr-depth + } } # if curr-word == final-word break compare curr-word, final-word |