ajout des types + union pour compil
This commit is contained in:
29
lfo.c
Normal file
29
lfo.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<time.h> /* Utilisé pour obtenir une adresse de démarrage aléatoire */
|
||||
|
||||
union mars_instruction {
|
||||
long long instruction;
|
||||
struct
|
||||
{
|
||||
unsigned char codeop;
|
||||
unsigned char modea;
|
||||
unsigned char modeb;
|
||||
unsigned char align;
|
||||
short int arga;
|
||||
short int argb;
|
||||
} mars;
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
|
||||
union mars_instruction toto;
|
||||
|
||||
toto.mars.codeop = 2;
|
||||
toto.mars.arga = 2;
|
||||
toto.mars.argb = 8;
|
||||
|
||||
printf("%llx\n", toto.instruction);
|
||||
|
||||
}
|
12
mars_main.c
12
mars_main.c
@@ -10,11 +10,11 @@ int main(int argc, char* argv[]){
|
||||
|
||||
if (argc < 3){
|
||||
printf("Vous n'avez pas rentrez assez d'arguments \n");
|
||||
printf("Exemple d'utilisation: %s fichier1.ass fichier2.ass\n", argv[0]);
|
||||
printf("Exemple d'utilisation: %s fichier1.cass fichier2.cass\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
} else if (argc > 3){
|
||||
printf("Vous avez utilisé trop d'arguments \n");
|
||||
printf("Exemple d'utilisation: %s fichier1.ass fichier2.ass\n", argv[0]);
|
||||
printf("Exemple d'utilisation: %s fichier1.cass fichier2.cass\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -32,13 +32,9 @@ int main(int argc, char* argv[]){
|
||||
printf("Fichier 1: %s\n", argv[1]);
|
||||
printf("Fichier 2: %s\n", argv[2]);
|
||||
|
||||
/* To do: faire le programme qui lit le fichier compilé */
|
||||
|
||||
fclose(fichier1);
|
||||
fclose(fichier2);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
/* To do: faire le programme qui lit le fichier compilé */
|
||||
}
|
||||
|
||||
void write_at_adresse(int adresse, int player, int valeur){
|
||||
return;
|
||||
}
|
||||
|
15
mars_types.h
15
mars_types.h
@@ -4,8 +4,19 @@
|
||||
|
||||
struct adresse {
|
||||
int player;
|
||||
int valeur;
|
||||
long long instruction; /* Instruction en long long */
|
||||
};
|
||||
|
||||
|
||||
union mars_instruction {
|
||||
long long instructLL;
|
||||
struct
|
||||
{
|
||||
unsigned char codeOp;
|
||||
unsigned char modeAddrA;
|
||||
unsigned char modeAddrB;
|
||||
unsigned char case_remplissage; /* Permet d'éviter un décalage dans le fichier */
|
||||
short int ArgA;
|
||||
short int ArgB;
|
||||
} instruct;
|
||||
};
|
||||
#endif
|
Reference in New Issue
Block a user