fix 3
This commit is contained in:
parent
4602c0aa77
commit
2b7de0b06b
1 changed files with 15 additions and 14 deletions
|
@ -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)
|
globals (res)
|
||||||
%rdi <- copy 5;
|
local compteur:
|
||||||
fact();
|
compteur <- copy 5;
|
||||||
res <- copy %rax;
|
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;
|
%rdi <- copy res;
|
||||||
print_int();
|
print_int();
|
||||||
end
|
end
|
||||||
|
|
Reference in a new issue