21 #define CHAMPION ((champion_t *)tmp->data)
160char *
read_file(
char *filepath,
int size,
int start);
char get_size_of_coding_byte(char coding_byte, bool max_size)
Get the size of the coding byte.
Definition coding_byte.c:48
void exec_sti(champion_t *champion, node_t *address)
The sti function.
Definition sti.c:71
struct corewar_s corewar_t
The corewar structure.
int analyse_champions(void)
Analyse each champion files and complete the champion structure.
Definition champion.c:72
void exec_st(champion_t *champion, node_t *address)
The st function.
Definition st.c:58
char get_code_byte_index(char coding_byte, int index)
Get the type of byte with the coding byte at the index.
Definition coding_byte.c:20
int read_int_in_address(node_t *address, int size)
Read int in address.
Definition instructions.c:83
void check_alive_champions(void)
Check if the champions are alive.
Definition state.c:18
int get_prog_size(char *header)
Get the program size.
Definition header.c:37
void exec_ldi(champion_t *champion, node_t *address)
The ldi function.
Definition ldi.c:86
void exec_ld(champion_t *champion, node_t *address)
The ld function.
Definition ld.c:57
int parse_args(int argc, char **argv)
Parse the arguments.
Definition parsing.c:104
void exec_xor(champion_t *champion, node_t *address)
The xor function.
Definition xor.c:86
corewar_t * get_corewar(void)
Get the corewar structure.
Definition corewar.c:18
char get_size_from_type(char type, bool max_size)
Get the size of the type.
Definition coding_byte.c:31
int champion_number_exist(int number)
Check if a champion number exist.
Definition champion.c:41
void execute_instructions(champion_t *champion)
Execute the instructions.
Definition instructions.c:19
struct champion_s champion_t
The champion structure.
struct cell_s cell_t
The cell structure.
void exec_lld(champion_t *champion, node_t *address)
The lld function.
Definition lld.c:57
void exec_lfork(champion_t *champion, node_t *address)
The lfork function.
Definition lfork.c:54
int get_int_from_address(node_t *address, int size)
Get int from address.
Definition instructions.c:49
int is_valid_magic(char *header)
Check if the magic number is valid.
Definition header.c:19
void update_program_counter(champion_t *champion, int value)
Update the program counter of a champion.
Definition update.c:20
void exec_sub(champion_t *champion, node_t *address)
The sub function.
Definition sub.c:20
void exec_lldi(champion_t *champion, node_t *address)
The lldi function.
Definition lldi.c:86
void exec_fork(champion_t *champion, node_t *address)
The fork function.
Definition fork.c:54
void exec_aff(champion_t *champion, node_t *address)
The aff function.
Definition aff.c:20
int build_arena(void)
Build the arena.
Definition arena.c:40
void exec_and(champion_t *champion, node_t *address)
The and function.
Definition and.c:86
void exec_zjmp(champion_t *champion, node_t *address)
The zjmp function.
Definition zjmp.c:20
void exec_or(champion_t *champion, node_t *address)
The or function.
Definition or.c:86
void free_corewar(void)
Free the corewar structure and all the memory allocated.
Definition corewar.c:38
void exec_live(champion_t *champion, node_t *address)
The live function.
Definition live.c:20
void update_carry(champion_t *champion, int value)
Update the carry of a champion.
Definition update.c:34
node_t * get_arena_node(int address)
Get the arena node from an address.
Definition arena.c:88
int get_next_champion_number(void)
Get the next champion number disponible.
Definition champion.c:18
int corewar(void)
The virtual machine of the corewar.
Definition corewar.c:55
void exec_add(champion_t *champion, node_t *address)
The add function.
Definition add.c:20
void display_winner(node_t *champions)
Display the winner.
Definition state.c:39
char * read_file(char *filepath, int size, int start)
Read a file and return the content.
Definition read_file.c:21
int check_champions_number(node_t *champions)
Check the number of champions.
Definition state.c:58
champion_t * get_champion_by_number(int number)
Get a champion by its number.
Definition champion.c:99
void display_arena(void)
Display the arena.
Definition arena.c:67
void write_int_in_address(champion_t *champion, node_t *address, int value)
Write int in address.
Definition instructions.c:66
The header file of the libmymemory.
The header file of the op.
The cell structure.
Definition corewar.h:32
The champion structure.
Definition corewar.h:41
The corewar structure.
Definition corewar.h:58