1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-12 14:28:08 +03:00
juvix/tests/Asm/positive/test033.jva
Łukasz Czajka 8e5f45f16f
Require semicolon to separate case/if branches in JuvixAsm syntax (#2574)
This makes the syntax more uniform. It was especially confusing with
nested branching, where some closing braces had to and others couldn't
be followed by a semicolon. Now all have to be followed by a semicolon
(except function ending braces).
2024-01-11 09:19:36 +00:00

82 lines
931 B
Plaintext

-- Ackermann function
function ack(integer, integer) : integer {
push 0;
push arg[0];
eq;
br {
true: {
push 1;
push arg[1];
add;
ret;
};
false: {
push 0;
push arg[1];
eq;
br {
true: {
push 1;
push 1;
push arg[0];
sub;
tcall ack;
};
false: {
push 1;
push arg[1];
sub;
push arg[0];
call ack;
push 1;
push arg[0];
sub;
tcall ack;
};
};
};
};
}
function main() {
push 7;
push 0;
call ack;
trace;
pop;
push 7;
push 1;
call ack;
trace;
pop;
push 13;
push 1;
call ack;
trace;
pop;
push 7;
push 2;
call ack;
trace;
pop;
push 13;
push 2;
call ack;
trace;
pop;
push 4;
push 3;
call ack;
trace;
pop;
push void;
ret;
}