diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-10-20 11:51:24 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-10-20 12:01:55 -0700 |
commit | 619dc31dfc565a2f8d76b6ab701b64394506f5ae (patch) | |
tree | e6fa4595c885f1582cdf7b6e89e5439aecdd0f68 /tutorial/add2.mu | |
parent | 909a0e2530142ea5bf506d66111a6ff75bf645e9 (diff) | |
download | mu-619dc31dfc565a2f8d76b6ab701b64394506f5ae.tar.gz |
sketching out a slow tutorial
Diffstat (limited to 'tutorial/add2.mu')
-rw-r--r-- | tutorial/add2.mu | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tutorial/add2.mu b/tutorial/add2.mu new file mode 100644 index 00000000..250d72ca --- /dev/null +++ b/tutorial/add2.mu @@ -0,0 +1,19 @@ +fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) { + var result/eax: int <- do-add 3, 4 + draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen screen, result, 3/fg=cyan 0/bg +} + +fn do-add a: int, b: int -> _/eax: int { + var result/eax: int <- copy a + result <- add b + return result +} + +fn test-do-add { + var observed/eax: int <- do-add 0, 0 + check-ints-equal observed, 0, "F - 0+0" + observed <- do-add 3, 0 + check-ints-equal observed, 3, "F - 3+0" + observed <- do-add 3, 2 + check-ints-equal observed, 5, "F - 3+2" +} |