From 99a8ea89e2954f011e1795955f8832bffad84df3 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 15 Jun 2020 23:06:07 -0700 Subject: 6539 - arith: start on mul/div --- apps/arith.mu | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'apps/arith.mu') diff --git a/apps/arith.mu b/apps/arith.mu index 18e572e4..6821efcf 100644 --- a/apps/arith.mu +++ b/apps/arith.mu @@ -23,7 +23,7 @@ fn simplify -> result/eax: int, look/esi: byte { # prime the pump look <- get-char # prime the pump look <- skip-spaces look - result, look <- num look + result, look <- term look $simplify:loop: { # operator var op/ecx: byte <- copy 0 @@ -38,7 +38,7 @@ fn simplify -> result/eax: int, look/esi: byte { look <- skip-spaces look { var tmp/eax: int <- copy 0 - tmp, look <- num look + tmp, look <- term look second <- copy tmp } # perform op @@ -61,6 +61,11 @@ fn simplify -> result/eax: int, look/esi: byte { look <- skip-spaces look } +fn term _look: byte -> result/eax: int, look/esi: byte { + look <- copy _look # should be a no-op + result, look <- num look +} + fn operator _look: byte -> op/ecx: byte, look/esi: byte { op <- copy _look look <- get-char -- cgit 1.4.1-2-gfad0