From 39734ccae6323a4279011f81ed8d64c2e8ac1756 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 19 Jun 2017 21:35:48 +0200 Subject: [PATCH] IML TD(take2): * Implement TD2 exercice 3 completly * Implement TD3 MIPS assembler MARS exercices MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .gitignore | 2 ++ TD1/part_two/exo.c | 8 +++--- TD2/exercise2/Makefile | 3 +++ TD2/exercise3/exercise.c | 3 +-- TD3/mips3.asm | 55 +++++++++++++++++++++++++++++++++------- exo_skel/Makefile | 3 +++ 6 files changed, 59 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 063ef1e..fd3edea 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,8 @@ balle *.swp *~ +*.txt + .build thumbs.db diff --git a/TD1/part_two/exo.c b/TD1/part_two/exo.c index 430e74c..2f5e419 100644 --- a/TD1/part_two/exo.c +++ b/TD1/part_two/exo.c @@ -1,11 +1,11 @@ -#include -#include - #include #include #include #include +#include +#include + void show_proc_pids() { pid_t current_pid = getpid(); pid_t parent_pid = getppid(); @@ -48,7 +48,7 @@ int main() { wait(NULL); exit(EXIT_SUCCESS); } - + /* unreachable code */ return EXIT_SUCCESS; } diff --git a/TD2/exercise2/Makefile b/TD2/exercise2/Makefile index 8c707d7..d3527af 100644 --- a/TD2/exercise2/Makefile +++ b/TD2/exercise2/Makefile @@ -67,6 +67,9 @@ $(DEPDIR)/%.d: ; include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS)))) +run: $(BINARY_NAME) + ./$(BINARY_NAME) + clean: @echo "[CLN]" -@rm -r $(BUILDDIR) diff --git a/TD2/exercise3/exercise.c b/TD2/exercise3/exercise.c index c4e9e41..1d20fc5 100644 --- a/TD2/exercise3/exercise.c +++ b/TD2/exercise3/exercise.c @@ -23,8 +23,7 @@ int main() { } else if (cpid == 0) { close(pipefd[0]); dup2(pipefd[1], STDOUT_FILENO); - printf("[%d] Hey Jude\n", getpid()); - //execl("/bin/ls", "ls", (char*)NULL); + execl("/bin/ls", "ls", (char*)NULL); close(pipefd[1]); exit(EXIT_SUCCESS); } else { diff --git a/TD3/mips3.asm b/TD3/mips3.asm index 080f63b..2f3018c 100644 --- a/TD3/mips3.asm +++ b/TD3/mips3.asm @@ -1,8 +1,10 @@ .data -msg_addition: .asciiz "Valeur attendue 97, obtenue" -msg_soustraction: .asciiz "Valeur attendue 63, obtenue" -msg_multiplication: .asciiz "Valeur attendue 6111, obtenue" -msg_division: .asciiz "Valeur attendue , obtenue" +msg_addition: .asciiz "Valeur attendue 97, obtenue " +msg_soustraction: .asciiz "Valeur attendue 63, obtenue " +msg_multiplication: .asciiz "Valeur attendue 6111, obtenue " +msg_division_quotient: .asciiz "Valeur quotient attendue 1, obtenue " +msg_division_reste: .asciiz "Valeur reste attendue 29, obtenue " +saut_de_ligne: .asciiz "\n" .text la $t1,34 la $t2,63 @@ -10,15 +12,50 @@ add $t3,$t2,$t1 la $a0,msg_addition li $v0,4 syscall +add $a0,$t3,$zero +li $v0,1 +syscall +la $a0,saut_de_ligne +li $v0,4 +syscall sub $t4,$t3,$t1 +la $a0,msg_soustraction +li $v0,4 +syscall +add $a0,$t4,$zero +li $v0,1 +syscall +la $a0,saut_de_ligne +li $v0,4 +syscall mult $t3,$t4 mflo $t5 +la $a0,msg_multiplication +li $v0,4 +syscall +add $a0,$t5,$zero +li $v0,1 +syscall +la $a0,saut_de_ligne +li $v0,4 +syscall div $t2,$t1 mflo $t6 mfhi $t7 - - - - +la $a0,msg_division_quotient +li $v0,4 +syscall +add $a0,$t6,$zero +li $v0,1 +syscall +la $a0,saut_de_ligne +li $v0,4 +syscall +la $a0,msg_division_reste +li $v0,4 +syscall +add $a0,$t7,$zero +li $v0,1 +syscall la $v0,10 -syscall \ No newline at end of file +syscall diff --git a/exo_skel/Makefile b/exo_skel/Makefile index 8adb5d0..5af208d 100644 --- a/exo_skel/Makefile +++ b/exo_skel/Makefile @@ -67,6 +67,9 @@ $(DEPDIR)/%.d: ; include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS)))) +run: $(BINARY_NAME) + ./$(BINARY_NAME) + clean: @echo "[CLN]" -@rm -r $(BUILDDIR) -- 2.34.1