implement prefix calculator

This commit is contained in:
jakob 2026-02-13 12:49:40 +01:00
parent 09178c6d94
commit 76257daea8
3 changed files with 226 additions and 2 deletions

31
calculator/README.md Normal file
View file

@ -0,0 +1,31 @@
# Calculator
This program accepts an arithmetic expression in prefix notation
on standard input and prints the result on standard output.
Supported operations:
- Addition
- Subtraction
- Multiplication
- Division
All calculations are preformed on Integers in range $[-2^{23}, 2^{23} - 1]$. Negative numbers can be written as `(- 0 n)`, where `n` is the number
Here are some examples:
```{bash}
(* 21 2)
00000042
(/ 6 (* 2 (+ 2 1)))
00000001
(* (/ 6 2) (+ 2 1))
00000009
(- 33 (* 4 25))
-00000067
```
- Source code: calc.asm
- Frequency: any (faster is faster)
- Author: Jakob Jesenko, 2026