First, you should convert the printing routine in the previous phase so that it prints each expression as a SPARC comment. (SPARC comments star with the ! character and continue to the end of the line.
Next, you should generate SPARC code for the expression trees built by the code in the previous phase. You do not need to generate code for all of the C operators. In particular, you do not need to generate code for the following operators:
symbols | operator names |
---|---|
() [] -> . | function call, array index, pointer dereference, member access |
! * & (type) sizeof | logical negation, pointer dereference, address of, type case, sizeof |
&& || ?: | logical and, logical or, conditional |
, | comma |
You should assume that every value and every variable refers to an integer (i.e., int).
Remember, make it work then try to generate good code.
Suggested steps: