-
Notifications
You must be signed in to change notification settings - Fork 0
/
cdb.c
65 lines (55 loc) · 1.32 KB
/
cdb.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
#include "definitions.h"
static int remaining_broadcasts;
bool there_are_free_broadcasts()
{
if (remaining_broadcasts > 0)
{
return true;
}
error(E_NO_CDB_AVAIL, ACTION_PRINTMSG);
return false;
}
static
bool get_available_bus()
{
if (remaining_broadcasts > 0)
{
remaining_broadcasts--;
return true;
}
return false;
}
static
bool broadcast_result_float(int *freg, double value)
{
if(get_available_bus())
{
//set_freg_value(*freg, value);
return true;
}
return false;
}
static
bool broadcast_result_int(int *rreg, int value)
{
if(get_available_bus())
{
//set_rreg_value(*rreg, value);
return true;
}
return false;
}
bool broadcast_result(ASMinstr* instr, double result)
{
bool wasBroadcasted = false;
//fprintf(stderr, "Broadcasting result of %s to register %d\n", getCmdStr(instr->instr.r.cmd), instr->instr.r.dstReg);
if( isRRinstrE(instr->instr.r.cmd) || isIinstrE(instr->instr.i.cmd) || isBinstrE(instr->instr.b.cmd) )
wasBroadcasted = broadcast_result_int(&instr->instr.r.dstReg, (int) result);
else
wasBroadcasted = broadcast_result_float(&instr->instr.r.dstReg, result);
return wasBroadcasted;
}
void update_cdb()
{
remaining_broadcasts = num_of_simultaneous_cdb_broadcasts;
}