Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me with this. I dont understand what to do. Please give me clear hin

ID: 3530680 • Letter: P

Question

Please help me with this. I dont understand what to do. Please give me clear hints or examples on how to solve this.



Build a symbol table. A symbol table is a list of all the labels used in the program given to the compiler. Each label corresponds to a variable or instruction. Building the symbol table consists of reading the input program.asm file that stores the assembly source code, and finding all the labels in it. (Hint: look for a colon.) Each label needs to be associated with a memory address. This can be determined by using an instruction counter or a data counter.



Explanation / Answer

A symbol table maps identifiers (typically prefixed by a scope name) to information about that identifier, such as its symbol type (local variable / parameter / function / class etc.), data type, its order relative to the other identifiers in the same scope, its source code line, etc. The symbol table can be generated by traversing the abstract syntax tree, by always keeping track of which scope you're in and adding information to the symbol table whenever you hit a variable declaration. In your example, a part of the symbol table might look like this (mapping to symbol type, data type, position, and source code line):

Now, you can resolve all variable references. For instance, in the expressionA := A + 1, if you know that your current scope isMULTIPLY.Aop, the symnbol table will let you find out that thisAis an input/output parameter of typeINT, and that it is the first parameter (this information will let you generate a stack address offset so that you can load/store the variable).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote