-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJType.cpp
More file actions
executable file
·29 lines (28 loc) · 996 Bytes
/
JType.cpp
File metadata and controls
executable file
·29 lines (28 loc) · 996 Bytes
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
#include<string>
#include<iostream>
#include<sstream>
#include"ir.h"
#include"label.h"
using namespace std;
string J_type(int head, string ins, string l[], int label_locate[])
{
int i, i_loc;
string addr="",label="";
//for (i = ins.rfind(" "); i <= ins.length(); i++)
i_loc = ins.rfind(' ') + 1;
if (ins[i_loc] >= '0'&&ins[i_loc] <= '9')
for (i = ins.rfind(" ") + 1; i < ins.length(); i++)
addr += ins[i];
else /*参数不是相对地址,而是一个label*/
{
for (i = ins.rfind(" ") + 1; i < ins.length(); i++)
label += ins[i];
for (i = 0; i <= LABEL_AT_MOST; i++)
if (label == l[i]) break;
int immi = label_locate[i]; /***********************************************************************/
ostringstream x; /**********************************************************************/
x << immi << endl; /*********************************************************************/
addr = x.str();
}
return "000010"+Turn_26_Bin(addr);
}