diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-10-20 14:35:18 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-10-20 14:35:18 -0700 |
commit | 3dead5564151b9f3f02cac638b6e526082d9818b (patch) | |
tree | 6272eb281bf86d8dc5c393bb04004a893cd57793 /tutorial/task5-solution.mu | |
parent | f263a2070b769a6365d442fd5f4a2fb6fefac3c8 (diff) | |
download | mu-3dead5564151b9f3f02cac638b6e526082d9818b.tar.gz |
task: variables in registers vs memory
Diffstat (limited to 'tutorial/task5-solution.mu')
-rw-r--r-- | tutorial/task5-solution.mu | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tutorial/task5-solution.mu b/tutorial/task5-solution.mu new file mode 100644 index 00000000..147cc77f --- /dev/null +++ b/tutorial/task5-solution.mu @@ -0,0 +1,18 @@ +fn foo -> _/eax: int { + var x: int + # statement 1: store 3 in x + copy-to x, 3 + # statement 2: define a new variable 'y' in register eax and store 4 in it + var y/eax: int <- copy 4 + # statement 3: add y to x, storing the result in x + add-to x, y + return x +} + +fn test-foo { + var result/eax: int <- foo + check-ints-equal result, 7, "F - foo should return 7, but didn't" +} + +fn main { +} |