-
Notifications
You must be signed in to change notification settings - Fork 2
/
sta.cpp
36 lines (32 loc) · 839 Bytes
/
sta.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
#include "library.h"
#include "tools.h"
extern string memory[65535];
extern int pc,start;
extern string reg[7];
void sta(string cmd[],int len)
{
if(len!=2)
cout<<" error :"<<pc<<"invalid no. of args"<<endl;
else
{
if(cmd[1]!="m" &&(validAddress(cmd[1])==0 || cmd[1].size()>4))
{
cout<<" error :"<<pc<<"invalid address"<<endl;
}
else
{
int addr;
string hexAddr;
if(cmd[1]=="m")
{
hexAddr=reg[5]+reg[6];
addr=hexToDec(hexAddr);
cout<<hexAddr<<endl;
}
else
addr=hexToDec(cmd[1]);
memory[addr]=reg[0];
cout<<"memory["<<cmd[1]<<"] = "<<memory[addr]<<endl;
}
}
}