View on GitHub

JST

By Janelle Blankenburg, Shubham Gogna, and Terence Henriod
UNR CS 660: Compiler Construction

Download this project as a .zip file Download this project as a tar.gz file

Do .. While

Input Source

int main()
{
    int i;
    do
    {
        i = 5;
    }
    while (i > 10);
}

3AC (Three-Address Code)

DATA           , -              , -              , -              
TEXT           , -              , -              , -              
CALL           , main           , 4              , -              
LLAC           , 4              , -              , -              
BR             , PROG_END       , -              , -              
# 
#             int main()
main:
#             {
#                 int i;
#                 do
BR             , label_00001    , -              , -              
label_00000:
#                 {
#                     i = 5;
#                 }
#                 while (i > 10);
LW             , ireg_00000     , 0($fp)         , -              
ADDIU          , ireg_00001     , $zero          , 10             
GT             , ireg_00002     , ireg_00000     , ireg_00001     
BRNE           , label_00001    , $zero          , ireg_00002     
BR             , label_00002    , -              , -              
label_00001:
ADDI           , ireg_00003     , 0($fp)         , 0              
ADDIU          , ireg_00004     , $zero          , 5              
ASSIGN         , ireg_00004     , ireg_00003     , ireg_00004     
BR             , label_00000    , -              , -              
label_00002:
JR             , $RA            , -              , -              
PROG_END:
#             }
#

Generated AST