diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-06-15 22:41:38 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-06-15 22:41:38 -0700 |
commit | 9f0e69f19b462f2d9cbff784790e8b411e427492 (patch) | |
tree | b59dffc7794b3e4efafbdc8ef7765331ed4533cc /apps | |
parent | 705dfd8587fab7d850163a3bbbca5075724ad946 (diff) | |
download | mu-9f0e69f19b462f2d9cbff784790e8b411e427492.tar.gz |
6535
Diffstat (limited to 'apps')
-rw-r--r-- | apps/arith.mu | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/apps/arith.mu b/apps/arith.mu index 2f41c5cd..4eef6127 100644 --- a/apps/arith.mu +++ b/apps/arith.mu @@ -20,44 +20,44 @@ fn main -> exit-status/ebx: int { } fn simplify -> result/eax: int, look/esi: byte { -$simplify:body: { - look <- get-char # prime the pump - # first arg - look <- skip-spaces look - { + $simplify:body: { + look <- get-char # prime the pump + # first arg + look <- skip-spaces look { - var is-digit?/eax: boolean <- is-decimal-digit? look - compare is-digit?, 0 # false - break-if-= $simplify:body + { + var is-digit?/eax: boolean <- is-decimal-digit? look + compare is-digit?, 0 # false + break-if-= $simplify:body + } + result, look <- num look } - result, look <- num look - } - # operator - var op/ecx: byte <- copy 0 - look <- skip-spaces look - op, look <- operator look - # second arg - var second/edx: int <- copy 0 - look <- skip-spaces look - { - var tmp/eax: int <- copy 0 - tmp, look <- num look - second <- copy tmp - } - # perform op - { - compare op, 0x2b # '+' - break-if-!= - result <- add second - break $simplify:body - } - { - compare op, 0x2d # '-' - break-if-!= - result <- subtract second - break $simplify:body - } -} # $simplify:body + # operator + var op/ecx: byte <- copy 0 + look <- skip-spaces look + op, look <- operator look + # second arg + var second/edx: int <- copy 0 + look <- skip-spaces look + { + var tmp/eax: int <- copy 0 + tmp, look <- num look + second <- copy tmp + } + # perform op + { + compare op, 0x2b # '+' + break-if-!= + result <- add second + break $simplify:body + } + { + compare op, 0x2d # '-' + break-if-!= + result <- subtract second + break $simplify:body + } + } # $simplify:body # trailing spaces look <- skip-spaces look } |