Structure Chart for Pass 2 of Assembler
The function declarations for the functions in this structure chart are
below:
char * getToken (char ** tokBegin, char ** tokEnd);
// Moves tokBegin and tokEnd to point to beginning and end of token
// Returns the beginning of the token if a token was found (the
// same address as tokBegin points to), or null if no token was
// found.
void getOpInfo (int line, char * instName,
char * format, int * code, int *numOperands);
// Takes instName (instruction name, e.g., "add") and returns
// format ('R', 'I', 'J'), code (opcode or funct number), and
// numOperands (number of operands needed by the instruction).
// Takes line number as input for printing error messages.
int getRegNbr (char * regName, int line);
// Takes register name (e.g., $t0) and returns register number.
// Takes line number as input for printing error messages.
void assembleRformat (int functcode, char * restOfStmt, int line);
// Takes functcode, pointer to the rest of the statement, and
// line number for printing error messages.
// Prints R-format instruction to standard output.
void assembleIformat (int opcode, char * restOfStmt, int line, LabelTable table);
// Takes opcode, pointer to the rest of the statement,
// line number (for printing error messages), and label table.
// Prints I-format instruction to standard output.
void assembleJformat (int opcode, char * restOfStmt, int line, LabelTable table);
// Takes opcode, pointer to the rest of the statement,
// line number (for printing error messages), and label table.
// Prints J-format instruction to standard output.
void printBin (int value, int length);
// Takes a numeric value and prints the binary format to
// standard output as characters. The length specifies how
// many binary digits to print.
// E.g., printBin (3, 5) would print 00011 to stdout (the binary
// representation for the number 3, expressed using 5 characters).
If you decide to implement these functions, these declarations (without the
explanatory comments) should be put in assembler.h.