-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
116 changed files
with
1,295 additions
and
181 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "IntermediateDef.h" | ||
TEMP newTemp(); | ||
LABEL newLabel(); | ||
result *newResult(int flag, TEMP t, LABEL l); | ||
arg* newArg(int flag, hash_ele* h, TEMP t, LABEL L, int num, float rnum, int width); | ||
op* newOp(int flag, TAG tag, TOKEN tkname); | ||
label* returnLabel(int flag, LABEL l, char* dataDef); | ||
quadruple* newQuad(arg *a1, arg *a2, op* op, LABEL *l, result *res); | ||
quadruple* generateIntermediateCode(ASTNodeIt* root); | ||
char* concat(const char *s1, const char *s2); | ||
arg* getArg(ASTNodeIt* ast); |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "Intermediate.h" | ||
|
||
quadruple *writeDataDefs(quadruple *code, FILE *fp){ | ||
while(code->operand->flag==0 && code->operand->u.tag==TAG_DECLARE){ | ||
if(code->a1->u.width==2) fprintf(fp, "%s\tdw\tdup(?)", code->L->u.dataDef); | ||
else fprintf(fp, "%s\tdd\tdup(?)", code->L->u.dataDef); | ||
code=code->next; | ||
} | ||
return code; | ||
} | ||
|
||
void writeCode(quadruple *code, FILE *fp){ | ||
while(code!=NULL){ | ||
if(code->operand->flag==0 && code->operand->u.tag==TAG_READ){ | ||
fprintf(fp, "\tMOV\tEDX, %d", (code->a2->u.width==2)? 3:5); | ||
fprintf(fp, "\tMOV\tECX, %s", code->a1->u.L->u.dataDef); | ||
fprintf(fp, "\tMOV\tEAX, 3"); | ||
fprintf(fp, "\tMOV\tEBX, EAX"); | ||
fprintf(fp, "\tINT\t80H"); | ||
} | ||
else if(code->operand->flag==0 && code->operand->u.tag==TAG_WRITE){ | ||
fprintf(fp, "\tMOV\tEDX, %d", (code->a2->u.width==2)? 3:5); | ||
fprintf(fp, "\tMOV\tECX, %s", code->a1->u.L->u.dataDef); | ||
fprintf(fp, "\tMOV\tEBX, 1"); | ||
fprintf(fp, "\tMOV\tEAX, 4"); | ||
fprintf(fp, "\tINT\t80H"); | ||
} | ||
else if(code->operand->flag==1 && (code->operand->u.tkname==TK_PLUS || code->operand->u.tkname==TK_MINUS || code->operand->u.tkname==TK_DIV || code->operand->u.tkname==TK_MUL)){ | ||
if(code->operand->u.tkname==TK_PLUS){ | ||
|
||
} | ||
else if(code->operand->u.tkname==TK_MINUS){ | ||
|
||
} | ||
else if(code->operand->u.tkname==TK_DIV){ | ||
|
||
} | ||
else if(code->operand->u.tkname==TK_MUL){ | ||
|
||
} | ||
} | ||
code = code->next; | ||
} | ||
fprintf(fp, "\tMOV\tEAX, 1"); | ||
fprintf(fp, "\tMOV\tEBX, 0"); | ||
fprintf(fp, "\tINT\t80H"); | ||
} | ||
|
||
void generateCode(ASTNodeIt *ast, char *filename){ | ||
FILE *fp = fopen(filename, "w"); | ||
quadruple *fullcode = generateIntermediateCode(ast); | ||
fprintf(fp,"SECTION .bss\n"); | ||
fprintf(fp,"\tlpBuffer: resb 18\n\tBuf_Len: equ $-lpBuffer\n"); | ||
fprintf(fp,"lft: RESW 8\nFOR_CTRL: RESW 8\nOUT: RESW 10\ntemp: RESW 1\nrgt: RESW 1\n"); | ||
quadruple *stmts = writeDataDefs(fullcode, fp); | ||
fprintf(fp,"SECTION .text\nglobal _start\n\n_start:\n"); | ||
writeCode(stmts, fp); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "Intermediate.h" | ||
|
||
quadruple *writeDataDefs(quadruple *code, FILE *fp); | ||
void writeCode(quadruple *code, FILE *fp); | ||
void generateCode(ASTNodeIt *ast, char *filename); |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Oops, something went wrong.