Проектировании транслятора (язык проектирования Си++) с языка Си++ на язык Ассемблер (Лабораторная работа № 1-4), страница 13

                                               fprintf(out,"\ncmp ax, "); printdata(Four.second); fprintf(out,"\njnle label%d\n", lab);

                                    }

                                    if (Four.op==4) // >=

                                    {

                                               fprintf(out,"mov ax, "); printdata(Four.first);

                                               fprintf(out,"\ncmp ax, "); printdata(Four.second); fprintf(out,"\njnge label%d\n", lab);

                                    }

                                    if (Four.op==5) // <

                                    {

                                               fprintf(out,"mov ax, "); printdata(Four.first);

                                               fprintf(out,"\ncmp ax, "); printdata(Four.second); fprintf(out,"\njnl label%d\n", lab);

                                    }

                                    if (Four.op==6) // >

                                    {

                                               fprintf(out,"mov ax, "); printdata(Four.first);

                                               fprintf(out,"\ncmp ax, "); printdata(Four.second); fprintf(out,"\njng label%d\n", lab);

                                    }

                                    operand.push_back(Oper);

                        }

                        k=sscanf(str+n, "%d%d%d", &a, &b, &c); // считывание терма

                        n+=6;

                        if (b>9) n++;

                        if (c>0) n++;

                        if (k<=0) // если постфикс закончился

                        {

                                    do{

                                               fgets(str,200,postfix1);

                                               k=sscanf(str, "%d%d%d", &a, &b, &c); // считывание терма

                                    }while (k<=0 && !feof(postfix1));

                                    i=0; n=6;

                                    operand.clear();

                                    fprintf(out,"\n");

                        }

            }         

            fprintf(out,"MOV ah,04Ch\n");

            fprintf(out,"int 21h\n");

            fprintf(out,"END START");

}

5.Тесты

5.1.

int main()

{

              int flag=0;

              while (flag<=54) g=g+524;

}

Файл const.txt

54

524

Файл ident.txt

flag

g

Файл razdel.txt

(

)

{

=

;

(

<=

)

=

+

;

5.2

int main()

{

              gh@

              int flag=0;

              while (flag<=54) g=g+524;

/*

i=0;

*/

фпцк

}

Файл const.txt

54

524

Файл ident.txt

flag

g

Файл razdel.txt

(

)

{

=

;

(

<=

)

=

+

;

}

Файл token.txt

10 0 0    10 2 0    20 7 0    20 8 0   

20 9 0   

10 0 0    30 31 0  20 2 0    40 0 0    20 11 0 

10 1 0    20 7 0    30 31 0  20 3 0    40 5 0    20 8 0    30 32 0  20 2 0    30 32 0  20 0 0    40 5 1            20 11 0 

20 10 0 

Файл error.txt

3 string: incorrect identifier - gh@

9 string: unknown symbol - ф

9 string: unknown symbol - п

9 string: unknown symbol - ц

9 string: unknown symbol - к

5.3

№1

test.txt

main()

{

            int g=0, a0=10;

            while (g<3)

            {

                        i=i+1;

                        int a0;

                        while (a0>=0) a0=a0-1;

                        g=g+1;

            }

            a0=i+100;

}

token.txt

0 0 2      1 0 7      1 0 8     

1 0 9     

0 0 0      2 32 0    1 0 2      3 0 0      1 0 12    2 26 0    1 0 2      3 1 0      1 0 11   

0 0 1      1 0 7      2 32 0    1 0 5      3 3 0      1 0 8     

1 0 9     

2 34 0    1 0 2      2 34 0    1 0 0      3 1 1      1 0 11