-
Notifications
You must be signed in to change notification settings - Fork 1
/
instruct_5_8.c
65 lines (56 loc) · 1.97 KB
/
instruct_5_8.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* instruct_5_8.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ydeineha <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/09/07 18:29:29 by ydeineha #+# #+# */
/* Updated: 2018/09/07 18:29:31 by ydeineha ### ########.fr */
/* */
/* ************************************************************************** */
#include "corewar.h"
void exec_sub(t_process *process, unsigned int *arg, t_arg_type *arg_type)
{
int res;
res = arg_fin(process, arg[0], arg_type[0]) -
arg_fin(process, arg[1], arg_type[1]);
process->reg[arg[2] - 1] = res;
if (res == 0)
process->carry = 1;
else
process->carry = 0;
}
void exec_and(t_process *process, unsigned int *arg, t_arg_type *arg_type)
{
int res;
res = arg_fin(process, arg[0], arg_type[0]) &
arg_fin(process, arg[1], arg_type[1]);
process->reg[arg[2] - 1] = res;
if (res == 0)
process->carry = 1;
else
process->carry = 0;
}
void exec_or(t_process *process, unsigned int *arg, t_arg_type *arg_type)
{
int res;
res = arg_fin(process, arg[0], arg_type[0]) |
arg_fin(process, arg[1], arg_type[1]);
process->reg[arg[2] - 1] = res;
if (res == 0)
process->carry = 1;
else
process->carry = 0;
}
void exec_xor(t_process *process, unsigned int *arg, t_arg_type *arg_type)
{
int res;
res = arg_fin(process, arg[0], arg_type[0]) ^
arg_fin(process, arg[1], arg_type[1]);
process->reg[arg[2] - 1] = res;
if (res == 0)
process->carry = 1;
else
process->carry = 0;
}