ACSE 2.0.3
Advanced Compiler System for Education
Loading...
Searching...
No Matches
Assembly code output

Functions to print the assembly code of the compiled program. More...

Functions

char * registerIDToString (t_regID regID, bool machineRegIDs)
bool printInstruction (t_instruction *inst, FILE *fp, bool machineRegIDs)
bool writeAssembly (t_program *program, const char *fn)

Detailed Description

Functions to print the assembly code of the compiled program.

At the end of compilation, the assembly code needs to be printed to a file to be later processed by the assembler. These functions are used to perform this task and related assembly printing operations when necessary for logging purposes.

Function Documentation

◆ printInstruction()

bool printInstruction ( t_instruction * inst,
FILE * fp,
bool machineRegIDs )

Print the specified instruction to a file.

Parameters
instThe instruction to be printed.
fpThe stream where to print the instruction.
machineRegIDsTrue if the instruction uses physical registers (i.e. register allocation has already been performed)
Returns
false if an error occurred while writing to the stream.

Definition at line 437 of file target_asm_print.c.

◆ registerIDToString()

char * registerIDToString ( t_regID regID,
bool machineRegIDs )

Format a register to a string.

Parameters
regIDThe register ID that needs to be formatted.
machineRegIDsTrue if the register ID needs to be treated as a physical register, false if the register ID is a temporary register.
Returns
The newly formatted string, which is owned by the caller and needs to be freed. NULL if regID refers to a non-existent register ID.

Definition at line 263 of file target_asm_print.c.

◆ writeAssembly()

bool writeAssembly ( t_program * program,
const char * fn )

Write the final assembly code for the program to the specified file.

Parameters
programThe program being compiled.
fnThe path of the output file.
Returns
false if an error occurred while writing to the file.

Definition at line 546 of file target_asm_print.c.