17.01.2013 Views

COMPORT – Compilador Portugol - Nilo Menezes

COMPORT – Compilador Portugol - Nilo Menezes

COMPORT – Compilador Portugol - Nilo Menezes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

void<br />

Enter (long size)<br />

{<br />

Put (PSH, LNK, SP, 4);<br />

Put (PSH, FP, SP, 4);<br />

Put (ADD, FP, 0, SP);<br />

Put (SUBI, SP, SP, size);<br />

}<br />

void<br />

Return (long size)<br />

{<br />

Put (ADD, SP, 0, FP);<br />

Put (POP, FP, SP, 4);<br />

Put (POP, LNK, SP, size + 4);<br />

Put (RET, 0, 0, LNK);<br />

}<br />

void<br />

Open (void)<br />

{<br />

curlev = 0;<br />

pc = 0;<br />

relx = 0;<br />

ClearReg ();<br />

}<br />

void<br />

Close (FILE * S, long globals)<br />

{<br />

Put (POP, LNK, SP, 4);<br />

Put (RET, 0, 0, LNK);<br />

}<br />

void<br />

EnterCmd (char *name)<br />

{<br />

strcpy (name, comname[cno]);<br />

comadr[cno] = pc * 4;<br />

cno++;<br />

}<br />

ComPort <strong>–</strong> <strong>Compilador</strong> <strong>Portugol</strong><br />

void<br />

Load (FILE * S)<br />

{<br />

long i = 0L, k;<br />

while (i < relx)<br />

{<br />

k = rel[i++];<br />

code[k] = (code[k] / 0x10000 * 0x10000) + (code[k] + MemSize) %<br />

0x10000;<br />

}<br />

RISC.Load (code, pc);<br />

fprintf (W, " code loaded\n");<br />

RISC.Execute (entry * 4, S, stderr);<br />

}<br />

void<br />

97

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!