-
Notifications
You must be signed in to change notification settings - Fork 2
/
INX.cpp
53 lines (50 loc) · 1.47 KB
/
INX.cpp
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
#include "library.h"
#include "tools.h"
extern string reg[7];
extern int flag[5],pc;
void inx(string cmd[], int len)
{
if(len!=2)
cout<<"error : invalid no. of args"<<endl;
else
{
if(validRegister(cmd[1])==0)
cout<<" error :"<<pc<<": invalid register"<<endl;
else
{
int regNo=registerNumber(cmd[1]);
if(regNo!=1 && regNo!=3 && regNo!=5 )
cout<<" error :"<<pc<<": invalid register"<<endl;
else
{
int dec=hexToDec(reg[regNo+1]);
if(dec<255)
{
dec++;
reg[regNo+1]=decToHex(dec);
string str=reg[regNo+1];
reverse(str.begin(),str.end());
reg[regNo+1]=str;
}
else
{
reg[regNo+1]="00";
dec=hexToDec(reg[regNo]);
//dec++;
if(dec<255)
{
dec++;
reg[regNo]=decToHex(dec);
string str=reg[regNo];
reverse(str.begin(),str.end());
reg[regNo]=str;
}
else
{
reg[regNo]="00";
}
}
}
}
}
}