1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-12 14:28:08 +03:00
juvix/tests/Asm/positive/test012.jva
Łukasz Czajka 76548e464a
Structured temporary stack manipulation in JuvixAsm (#2554)
* Replaces the `pusht` and `popt` instructions with block-based `save`
and `tsave`. This encodes the structure of temporary stack manipulation
syntactically, making it impossible to manipulate it in unexpected ways.
Also simplifies compilation to Nock.
* Adds optional names for temporaries and function arguments.
2023-12-15 12:55:53 +00:00

37 lines
526 B
Plaintext

-- temporary stack
function main() {
push 1;
tsave {
push 2;
save {
push tmp[1];
};
push tmp[0];
add;
tsave {
push tmp[1];
push tmp[1];
mul;
tsave {
push tmp[2];
push 2;
add;
tsave {
push tmp[2];
push tmp[3];
add;
tsave {
push tmp[2];
push tmp[3];
push tmp[4];
add;
add;
ret;
};
};
};
};
};
}