diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-02-11 22:03:09 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-02-11 22:04:09 -0800 |
commit | 2ffd995524ef5dc7fee86136b3fa0cb8247fb6b7 (patch) | |
tree | 044ae4100a1ce6a9457effafff5c08a1d8b17290 /baremetal/shell | |
parent | 8b95a1be65b857b1a48e93a2ac8223253315a332 (diff) | |
download | mu-2ffd995524ef5dc7fee86136b3fa0cb8247fb6b7.tar.gz |
7727 - baremetal/shell: 1+1
Diffstat (limited to 'baremetal/shell')
-rw-r--r-- | baremetal/shell/eval.mu | 25 | ||||
-rw-r--r-- | baremetal/shell/line.mu | 7 | ||||
-rw-r--r-- | baremetal/shell/value-stack.mu | 3 |
3 files changed, 35 insertions, 0 deletions
diff --git a/baremetal/shell/eval.mu b/baremetal/shell/eval.mu index 2fc32a93..4352b540 100644 --- a/baremetal/shell/eval.mu +++ b/baremetal/shell/eval.mu @@ -236,3 +236,28 @@ fn evaluate _in: (addr line), end: (addr word), out: (addr value-stack) { loop } } + +fn test-eval-arithmetic { + # in + var in-storage: line + var in/esi: (addr line) <- address in-storage + parse-line "1 1 +", in + # end + var w-ah/eax: (addr handle word) <- get in, data + var end-h: (handle word) + var end-ah/ecx: (addr handle word) <- address end-h + final-word w-ah, end-ah + var end/eax: (addr word) <- lookup *end-ah + # out + var out-storage: value-stack + var out/edi: (addr value-stack) <- address out-storage + initialize-value-stack out, 8 + # + evaluate in, end, out + # + var len/eax: int <- value-stack-length out + check-ints-equal len, 1, "F - test-eval-arithmetic stack size" + var n/xmm0: float <- pop-number-from-value-stack out + var n2/eax: int <- convert n + check-ints-equal n2, 2, "F - test-eval-arithmetic result" +} diff --git a/baremetal/shell/line.mu b/baremetal/shell/line.mu index 70b0184c..f3d8d261 100644 --- a/baremetal/shell/line.mu +++ b/baremetal/shell/line.mu @@ -61,6 +61,13 @@ fn render-line screen: (addr screen), _line: (addr line), x: int, y: int, render return result } +fn parse-line in: (addr array byte), _out: (addr line) { + var out/edi: (addr line) <- copy _out + initialize-line out + var dest/eax: (addr handle word) <- get out, data + parse-words in, dest +} + #? fn main { #? # line = [aaa, bbb, ccc, ddd] #? var line-storage: line diff --git a/baremetal/shell/value-stack.mu b/baremetal/shell/value-stack.mu index c456f2e5..1ea4180f 100644 --- a/baremetal/shell/value-stack.mu +++ b/baremetal/shell/value-stack.mu @@ -1,3 +1,6 @@ +# value stacks encode the result of a program at a single point in time +# they are typically rendered vertically + type value-stack { data: (handle array value) top: int |