From e4b1d10007030a3a1dfd3b116acf00fcba4aaedc Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 31 Dec 2023 23:16:39 +0100 Subject: [PATCH] exit --- flap/questions/retrolixToX86_64/02.retrolix | 18 +----------------- flap/questions/retrolixToX86_64/03.retrolix | 6 ++---- flap/questions/retrolixToX86_64/04.retrolix | 2 ++ flap/questions/retrolixToX86_64/05.retrolix | 2 ++ flap/questions/retrolixToX86_64/06.retrolix | 15 +++++++++------ flap/questions/retrolixToX86_64/07.retrolix | 16 ++++++++-------- flap/questions/retrolixToX86_64/08.retrolix | 2 ++ flap/src/x86-64/retrolixToX86_64.ml | 2 +- 8 files changed, 27 insertions(+), 36 deletions(-) diff --git a/flap/questions/retrolixToX86_64/02.retrolix b/flap/questions/retrolixToX86_64/02.retrolix index 5157e5d..d310d71 100644 --- a/flap/questions/retrolixToX86_64/02.retrolix +++ b/flap/questions/retrolixToX86_64/02.retrolix @@ -1,24 +1,8 @@ globals (x, y, z, k) x <- copy 6; - %rdi <- copy x; - print_int(); - %rdi <- copy " "; - print_string(); - y <- copy 7; - %rdi <- copy y; - print_int(); - %rdi <- copy " "; - print_string(); - z <- mul y, x; - %rdi <- copy z; - print_int(); - %rdi <- copy " "; - print_string(); - k <- sub z, x; - %rdi <- copy k; - print_int(); + exit; end diff --git a/flap/questions/retrolixToX86_64/03.retrolix b/flap/questions/retrolixToX86_64/03.retrolix index 383774a..8c45d15 100644 --- a/flap/questions/retrolixToX86_64/03.retrolix +++ b/flap/questions/retrolixToX86_64/03.retrolix @@ -1,11 +1,9 @@ globals (res) - res <- copy 1; - res <- mul res, 5; + res <- mul 1, 5; res <- mul res, 4; res <- mul res, 3; res <- mul res, 2; res <- mul res, 1; - %rdi <- copy res; - print_int(); + exit; end diff --git a/flap/questions/retrolixToX86_64/04.retrolix b/flap/questions/retrolixToX86_64/04.retrolix index de73b80..b514a88 100644 --- a/flap/questions/retrolixToX86_64/04.retrolix +++ b/flap/questions/retrolixToX86_64/04.retrolix @@ -1,4 +1,6 @@ globals () %rdi <- copy 42; observe_int(); + + exit; end diff --git a/flap/questions/retrolixToX86_64/05.retrolix b/flap/questions/retrolixToX86_64/05.retrolix index 3fa8f67..f798653 100644 --- a/flap/questions/retrolixToX86_64/05.retrolix +++ b/flap/questions/retrolixToX86_64/05.retrolix @@ -9,4 +9,6 @@ globals () %rdi <- copy %rax; observe_int(); + + exit; end diff --git a/flap/questions/retrolixToX86_64/06.retrolix b/flap/questions/retrolixToX86_64/06.retrolix index 71a1611..3091011 100644 --- a/flap/questions/retrolixToX86_64/06.retrolix +++ b/flap/questions/retrolixToX86_64/06.retrolix @@ -1,12 +1,15 @@ def fact () + local n: + n <- copy %rdi; + %rax <- copy 1; condition: - jumpif lte %rdi, 1 -> fin, boucle; + jumpif lte n, 1 -> fin, boucle; boucle: - %rax <- mul %rax, %rdi; - %rdi <- sub %rdi, 1; + %rax <- mul %rax, n; + n <- sub n, 1; jump condition; fin: @@ -14,12 +17,12 @@ def fact () end globals (x) - x <- copy 5; - - %rdi <- copy x; + %rdi <- copy 5; fact(); x <- copy %rax; %rdi <- copy x; observe_int(); + + exit; end diff --git a/flap/questions/retrolixToX86_64/07.retrolix b/flap/questions/retrolixToX86_64/07.retrolix index 0e0516e..077e884 100644 --- a/flap/questions/retrolixToX86_64/07.retrolix +++ b/flap/questions/retrolixToX86_64/07.retrolix @@ -1,26 +1,26 @@ def fact () - local x: - jumpif lte %rdi, 1 -> fini, rec; + local n: + n <- copy %rdi; + jumpif lte n, 1 -> fini, rec; fini: %rax <- copy 1; ret; rec: - x <- copy %rdi; - %rdi <- sub %rdi, 1; + %rdi <- sub n, 1; fact(); - %rax <- mul %rax, x; + %rax <- mul %rax, n; ret; end globals (x) - x <- copy 5; - - %rdi <- copy x; + %rdi <- copy 5; fact(); x <- copy %rax; %rdi <- copy x; observe_int(); + + exit; end diff --git a/flap/questions/retrolixToX86_64/08.retrolix b/flap/questions/retrolixToX86_64/08.retrolix index ea0c8d3..1a7be26 100644 --- a/flap/questions/retrolixToX86_64/08.retrolix +++ b/flap/questions/retrolixToX86_64/08.retrolix @@ -20,4 +20,6 @@ globals () %rdi <- copy %rax; observe_int(); + + exit; end diff --git a/flap/src/x86-64/retrolixToX86_64.ml b/flap/src/x86-64/retrolixToX86_64.ml index 7237741..d1196d1 100644 --- a/flap/src/x86-64/retrolixToX86_64.ml +++ b/flap/src/x86-64/retrolixToX86_64.ml @@ -549,7 +549,7 @@ module FrameManager (IS : InstructionSelector) : FrameManager = struct ;; let call fd ~kind ~f ~args = - (* TODO: je segfault.. *) + (* TODO *) (* Appelle la fonction *) [ T.Instruction (T.calldi ~tgt:f) ] ;;