This commit is contained in:
Mylloon 2023-12-31 15:55:37 +01:00
parent 4602c0aa77
commit 2b7de0b06b
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,16 +1,17 @@
def fact ()
%rax <- copy 1;
boucle: jumpif lte %rdi, 1 -> fin, suite;
suite: %rax <- mul %rax, %rdi;
%rdi <- sub %rdi, 1;
jump boucle;
fin: ret;
end
globals (res)
%rdi <- copy 5;
fact();
res <- copy %rax;
%rdi <- copy res;
print_int();
local compteur:
compteur <- copy 5;
res <- copy 1;
condition:
jumpif lte compteur, 1 -> fin, boucle;
boucle:
res <- mul res, compteur;
compteur <- sub compteur, 1;
jump condition;
fin:
%rdi <- copy res;
print_int();
end