-
Notifications
You must be signed in to change notification settings - Fork 0
/
Debug.h
66 lines (61 loc) · 1.75 KB
/
Debug.h
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
#include <iostream>
#include <bitset>
#define BOOST_LOG_DYN_LINK
#include <boost/log/attributes.hpp>
#include <boost/log/common.hpp>
#include <boost/log/core.hpp>
#include <boost/log/exceptions.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks.hpp>
#include <boost/log/trivial.hpp>
/*
* takes in the values of each subset of an R instruction, and returns the
* integer value of the instruction
*/
unsigned int constructRInstr(unsigned int rs, unsigned int rt, unsigned int rd,
unsigned int shamt, unsigned int func){
unsigned int instr = 0;
instr += rs << 21;
instr += rt << 16;
instr += rd << 11;
instr += shamt << 6;
instr += func;
return instr;
}
/*
* takes in the values of each subset of an I instruction, and returns the
* integer value of the instruction
*/
unsigned int constructIInstr(unsigned int opcode, unsigned char rs,
unsigned char rtOrRD, unsigned short val){
unsigned int instr = 0;
instr += opcode << 26;
instr += rs << 21;
instr += rtOrRD << 16;
instr += val;
return instr;
}
/*
* takes in the values of each subset of an J instruction, and returns the
* integer value of the instruction.
* Really don't use a value outside permisible range of 28 bytes
*/
unsigned int constructJInstr(unsigned int opcode, unsigned int val){
unsigned int instr = 0;
instr += opcode << 26;
instr += val;
return instr;
}
//TODO I can't use severity?
//https://www.boost.org/doc/libs/1_79_0/libs/log/doc/html/log/tutorial/sinks.html
//void initLog(){
// //either missing header or dynamic invocation removes it
// //boost::log::add_file_log("out.log");
//
// //filter the log
// boost::log::core::get()->set_filter
// (
// boost::log::trivial::severity >= boost::log::trivial::info
// );
//
//}