je ne dors plus
This commit is contained in:
6
Makefile
6
Makefile
@@ -1,8 +1,10 @@
|
|||||||
OFILES = mars_main.o
|
OFILES = mars_main.o
|
||||||
main.out: $(OFILES)
|
main.out: $(OFILES)
|
||||||
gcc ${OFILES} -o main.out -lgraph
|
gcc ${OFILES} -o main.out -lgraph
|
||||||
mars_main.o: mars_main.c mars_types.h
|
mars_main.o: mars_main.c mars_types.h options.h
|
||||||
gcc -c mars_main.c
|
gcc -c mars_main.c
|
||||||
clean:
|
clean:
|
||||||
rm *.o *.out
|
rm *.o *.out
|
||||||
.PHONY: clean
|
clear:
|
||||||
|
rm *.o *.out
|
||||||
|
.PHONY: clean clear
|
48
mars_main.c
48
mars_main.c
@@ -1,12 +1,46 @@
|
|||||||
#include<stdio.h>
|
#include<stdio.h>
|
||||||
#include<stdlib.h>
|
#include<stdlib.h>
|
||||||
|
#include<string.h>
|
||||||
#include<time.h> /* Utilisé pour obtenir une adresse de démarrage aléatoire */
|
#include<time.h> /* Utilisé pour obtenir une adresse de démarrage aléatoire */
|
||||||
#include"mars_types.h" /* importe les types utilisés dans le programme */
|
#include"mars_types.h" /* importe les types utilisés dans le programme */
|
||||||
|
#include"options.h" /* Inclus les options du programme */
|
||||||
|
|
||||||
|
void initialiser_memoire(); /* Va initialiser la mémoire en plaçant les deux programmes dans des adresses aléatoires */
|
||||||
|
|
||||||
|
int calculer_position(); /* Va permettre de calculer la position à laquelle le programme doit effectuer une action*/
|
||||||
|
|
||||||
|
void execute_instruction(union mars_instruction instruction, int player, struct adresse memoire[8000], int position[2]){
|
||||||
|
short int operation = instruction.instruct.codeOp;
|
||||||
|
|
||||||
|
if(operation == MOV){
|
||||||
|
/* Transfère contenu adresse A à Adresse B */
|
||||||
|
printf("on a demandé un mov noice\n");
|
||||||
|
} else if (operation == ADD){
|
||||||
|
/* Ajoute contenu adresse A à adresse B */
|
||||||
|
printf("test");
|
||||||
|
} else if (operation == SUB){
|
||||||
|
/* Soustrait contenu adresse A à l'adresse B */
|
||||||
|
} else if (operation == JMP){
|
||||||
|
/* On saute à la position demandée par l'instruction */
|
||||||
|
} else if (operation == JMZ){
|
||||||
|
/* Transferer execution à adresse A si contenu adresse b = 0*/
|
||||||
|
} else if (operation == JMG){
|
||||||
|
/* Transferer execution à l'adresse A si contenu B > 0 */
|
||||||
|
} else if (operation == DJZ){
|
||||||
|
/* Retrancher 1 du contenu de l'adresse B et sauter à l'adresse A si seulement resultat = 0 */
|
||||||
|
}else if (operation == CMP){
|
||||||
|
/* Compare deux adresses, si différents sauter l'instruction suivante */
|
||||||
|
}else if (operation == DAT){
|
||||||
|
/* Cette instruction ne peut pas être exécutée, elle permet de contenir une valeur */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]){
|
int main(int argc, char* argv[]){
|
||||||
int position_player1, position_player2; /* Permet de connaître la position des joueurs dans la mémoire */
|
srand(time(NULL)); /* Initialise le pseudo aléatoire pour tout le programme */
|
||||||
struct adresse memoire[8000]; // Initialisation de la mémoire 0->7999
|
|
||||||
|
struct adresse memoire[TAILLE_MEM]; // Initialisation de la mémoire 0->7999
|
||||||
|
int position[2] = {0,0}; /* Position des joueurs */
|
||||||
|
|
||||||
if (argc < 3){
|
if (argc < 3){
|
||||||
printf("Vous n'avez pas rentrez assez d'arguments \n");
|
printf("Vous n'avez pas rentrez assez d'arguments \n");
|
||||||
@@ -36,5 +70,15 @@ int main(int argc, char* argv[]){
|
|||||||
|
|
||||||
fclose(fichier1);
|
fclose(fichier1);
|
||||||
fclose(fichier2);
|
fclose(fichier2);
|
||||||
|
|
||||||
|
union mars_instruction to_do;
|
||||||
|
to_do.instruct.codeOp = 1;
|
||||||
|
to_do.instruct.ArgA = 7909;
|
||||||
|
to_do.instruct.ArgB = 100;
|
||||||
|
to_do.instruct.modeAddrA = 1;
|
||||||
|
to_do.instruct.modeAddrB = 2;
|
||||||
|
printf("Valeur instruction: %lld\n", to_do.instructLL);
|
||||||
|
execute_instruction(to_do, 1, memoire, position);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
#ifndef MARS_TYPES_H
|
#ifndef MARS_TYPES_H
|
||||||
|
|
||||||
#define MARS_TYPES_H
|
#define MARS_TYPES_H
|
||||||
|
|
||||||
struct adresse {
|
struct adresse {
|
||||||
@@ -19,4 +18,9 @@ union mars_instruction {
|
|||||||
short int ArgB;
|
short int ArgB;
|
||||||
} instruct;
|
} instruct;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Listes des opérations possibles */
|
||||||
|
|
||||||
|
enum liste_operations {DAT,MOV, ADD, SUB, JMP, JMZ, JMG, DJZ, CMP};
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user