COMPORT – Compilador Portugol - Nilo Menezes
COMPORT – Compilador Portugol - Nilo Menezes
COMPORT – Compilador Portugol - Nilo Menezes
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
CODEGENERATOR.CPP<br />
ComPort <strong>–</strong> <strong>Compilador</strong> <strong>Portugol</strong><br />
/*<br />
* Módulo OSG - Code Generator Universidade do Amazonas Comport -<br />
* <strong>Compilador</strong> <strong>Portugol</strong> Aluno: <strong>Nilo</strong> Ney Coutinho <strong>Menezes</strong><br />
*<br />
* Baseado no compilador Oberon-0 de Niklaus Wirth<br />
*<br />
*/<br />
#define CODEGENERATOR<br />
#include <br />
#include <br />
#include <br />
#include "scanner.h"<br />
#include "instrucoes.h"<br />
#include "risc.h"<br />
#include "funcoes.h"<br />
#include "codegenerator.h"<br />
// int curlev, pc;<br />
Type boolType, intType, litType;<br />
int curlev, pc;<br />
int relx, cno;<br />
long entry, fixlist;<br />
char regs[32]; // Verificar troca por SET -- forcar o<br />
// ClearReg!!!<br />
extern FILE *W;<br />
long code[maxCode];<br />
int rel[maxRel];<br />
Ident comname[NofCom];<br />
long comadr[NofCom];<br />
char mnemo[54][5];<br />
void<br />
ClearReg ()<br />
{<br />
int i;<br />
for (i = 0; i < 32; i++)<br />
regs[i] = 0;<br />
}<br />
void<br />
GetReg (long &r)<br />
{<br />
int i;<br />
for (i = 1; (i < FP && !regs[i]); i++);<br />
regs[i] = 1;<br />
r = i;<br />
}<br />
87