This repository has been archived on 2024-01-18. You can view files and clone it, but cannot push or open issues or pull requests.
compilation/flap/questions/retrolixToX86_64/07.retrolix

27 lines
307 B
Text
Raw Permalink Normal View History

2023-12-31 16:03:27 +01:00
def fact ()
2023-12-31 23:16:39 +01:00
local n:
n <- copy %rdi;
jumpif lte n, 1 -> fini, rec;
2023-12-31 16:03:27 +01:00
fini:
%rax <- copy 1;
ret;
rec:
2023-12-31 23:16:39 +01:00
%rdi <- sub n, 1;
2023-12-31 16:03:27 +01:00
fact();
2023-12-31 23:16:39 +01:00
%rax <- mul %rax, n;
2023-12-31 16:03:27 +01:00
ret;
end
globals (x)
2023-12-31 23:16:39 +01:00
%rdi <- copy 5;
2023-12-31 16:03:27 +01:00
fact();
x <- copy %rax;
%rdi <- copy x;
observe_int();
2023-12-31 23:16:39 +01:00
exit;
2023-12-31 16:03:27 +01:00
end