Originally Posted by
Sebastiani
Post the code you're working with (because what you're describing doesn't make a whole lot of sense).
my project is to build an assembler for a mips program i wrote
i have this map in my main function:
Code:
string printCode(string, string&)
int main()
{
map <string, int> labList;
.
.
.
while(!file_read.eof())
{
string s,t,u;
getline(file_read, line,'\n');
addec=makeAddress(lineNumber);
file_write<<setfill('0')<<setw(8)<<hex<<addec;
file_write<<": ";
t=printCode (line,u);
if (t=="label")
{
file_write<<"<"<<u.erase((u.length()-1),1)<<">"<<endl;
labList[u]=addec;
}
that as it loops through this while code, it saves the address of labels in the map as they [the labels] come up.
i have an idea that involves passing in the map labList into the printCode function (which finds the binary of each line in mips). to get printCode to properly make branch functions, it needs a list of labels and their addresses, hence the map.
i tried prototyping a fuction like
Code:
void function (string, map);
but it throws an error with map as a parameter.
thus my question is: Can i pass std maps as parameters to functions, kinda like passing a pointer to an array