2020-07-05 22:28:37 +00:00
|
|
|
# Add 3 and 4, and return the result in the exit code.
|
2020-01-02 04:31:01 +00:00
|
|
|
#
|
|
|
|
# To run:
|
|
|
|
# $ ./translate_mu apps/ex2.mu
|
|
|
|
# $ ./a.elf
|
|
|
|
# Expected result:
|
|
|
|
# $ echo $?
|
|
|
|
# 7
|
|
|
|
|
2020-11-02 06:02:13 +00:00
|
|
|
fn main -> _/ebx: int {
|
|
|
|
var result/eax: int <- do-add 3 4
|
|
|
|
return result
|
2020-01-02 04:31:01 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 06:02:13 +00:00
|
|
|
fn do-add a: int, b: int -> _/eax: int {
|
2020-11-16 07:51:40 +00:00
|
|
|
var result/ecx: int <- copy a
|
2020-01-02 04:31:01 +00:00
|
|
|
result <- add b
|
2020-11-02 06:02:13 +00:00
|
|
|
return result
|
2020-01-02 04:31:01 +00:00
|
|
|
}
|