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)
|
||||
%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
|
||||
|
|
Reference in a new issue