I cannot access the readings, but this homework appears to be a departure from what you have done so far. It requires you to use programming skills you have gained from other classes.
You need to write a program (in C++ or whatever language your professor accepts) to read a file, given by the user.
Your program will read the file
twice.
The first time, it is just looking for
where things go. This is pretty easy since all your opcodes appear to be one word wide, and each word has its own address.
Once you have a table of symbol-name to index/location, print it out.
The second time you read the file in order to create the output assembly, using your symbol table to properly compile the opcodes.
For example, the LOAD opcode is 1000 + address of word to load. Since the symbol "X" refers to the word at location 104, the complete opcode is 1104. Notice that all the opcodes and addresses/locations are given in hexadecimal.
To get the filename from the user, I recommend you use
main()'s arguments:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
// here's some pseudo-code to get started
int main( int argc, char** argv )
{
if (argc != 2) complain();
const char* filename = argv[ 1 ];
create_symbol_table( filename );
assemble( filename );
return 0;
}
| |
Start with that and see where you can go from there. For example, which standard container will you use to store your symbol table? How will you check to see that the input does not contain the same symbol more than once?
See how far you can get with that.