-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFunctions.php
104 lines (89 loc) · 3.42 KB
/
Functions.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?hh
require_once('Registers.php');
function recursive_array_search($needle,$haystack)
{
foreach($haystack as $key=>$value)
{
$current_key=$key;
if($needle===$value || ( is_array($value) && recursive_array_search($needle,$value) !== false ) )
{
return $current_key;
}
}
return false;
}
function LDA ($Variable)
{
// $Variable hold the data which need to be Moved to A register
if( preg_match('/^[#]/', $Variable) )
{
//$Variable contains a immediate value
$Chars = preg_split('/^[#]/',$Variable);
//var_dump($Chars);
$GLOBALS['Register']['A']['CurrentValue'] = $Chars['1'];
$GLOBALS['Flages']['N']['Value'] = 0;
}
else if(preg_match('/^[@]/',$Variable))
{
$Chars = preg_split('/^[#]/',$Variable);
//var_dump($Chars);
$GLOBALS['Register']['A']['CurrentValue'] = $Chars['1'];
$GLOBALS['Flages']['I']['Value'] = 0;
}
else
{
$GLOBALS['Register']['A']['CurrentValue'] = $GLOBALS['Variables'][$Variable]['CurrentValue'];
}
}
function ADD ($Variable)
{
$GLOBALS['Register']['A']['CurrentValue'] = $GLOBALS['Register']['A']['CurrentValue'] + $GLOBALS['Variables'][$Variable]['CurrentValue'];
}
function ADDF ($Variable)
{
$GLOBALS['Register']['A']['CurrentValue'] = $GLOBALS['Register']['A']['CurrentValue'] + $GLOBALS['Variables'][$Variable]['CurrentValue'];
}
function ADDR ($Variable)
{
$Chars = preg_split('/[,]/',$Variable);
$GLOBALS['Register'][$Chars['1']]['CurrentValue'] = $GLOBALS['Register'][$Chars['1']]['CurrentValue'] + $GLOBALS['Register'][$Chars['0']]['CurrentValue'];
}
function DIV ($Variable)
{
$GLOBALS['Register']['A']['CurrentValue'] = $GLOBALS['Register']['A']['CurrentValue'] / $GLOBALS['Variables'][$Variable]['CurrentValue'];
}
function DIVF ($Variable)
{
$GLOBALS['Register']['A']['CurrentValue'] = $GLOBALS['Register']['A']['CurrentValue'] / $GLOBALS['Variables'][$Variable]['CurrentValue'];
}
function DIVR ($Variable)
{
$Chars = preg_split('/[,]/',$Variable);
$GLOBALS['Register'][$Chars['1']]['CurrentValue'] = $GLOBALS['Register'][$Chars['1']]['CurrentValue'] / $GLOBALS['Register'][$Chars['0']]['CurrentValue'];
}
function MUL ($Variable)
{
$GLOBALS['Register']['A']['CurrentValue'] = $GLOBALS['Register']['A']['CurrentValue'] * $GLOBALS['Variables'][$Variable]['CurrentValue'];
}
function MULF ($Variable)
{
$GLOBALS['Register']['A']['CurrentValue'] = $GLOBALS['Register']['A']['CurrentValue'] * $GLOBALS['Variables'][$Variable]['CurrentValue'];
}
function MULR ($Variable)
{
$Chars = preg_split('/[,]/',$Variable);
$GLOBALS['Register'][$Chars['1']]['CurrentValue'] = $GLOBALS['Register'][$Chars['1']]['CurrentValue'] * $GLOBALS['Register'][$Chars['0']]['CurrentValue'];
}
function SUB ($Variable)
{
$GLOBALS['Register']['A']['CurrentValue'] = $GLOBALS['Register']['A']['CurrentValue'] - $GLOBALS['Variables'][$Variable]['CurrentValue'];
}
function SUBF ($Variable)
{
$GLOBALS['Register']['A']['CurrentValue'] = $GLOBALS['Register']['A']['CurrentValue'] - $GLOBALS['Variables'][$Variable]['CurrentValue'];
}
function SUBR ($Variable)
{
$Chars = preg_split('/[,]/',$Variable);
$GLOBALS['Register'][$Chars['1']]['CurrentValue'] = $GLOBALS['Register'][$Chars['1']]['CurrentValue'] - $GLOBALS['Register'][$Chars['0']]['CurrentValue'];
}