handle comments in assembly source file

This commit is contained in:
Sam Hadow 2024-03-28 13:16:41 +01:00
parent ee34fc8d14
commit bcb627f2b4
2 changed files with 9 additions and 11 deletions

View File

@ -1,11 +1,9 @@
(2,4,5) (2,4,5)
ADD(i1,0,r0) ADD(i1,0,r0) // r0 temp value to calculate
ADD(i1,0,r1) ADD(1,0,r1) // r1 loop counter
ADD(i1,0,r2) JE(i2,r1,4) // loop control (r1 == b)
ADD(1,0,r3) MULT(i1,r0,r0) // r0 = r0*a
JE(i2,r3,4) ADD(1,r1,r1) // increment loop counter
MULT(r2,r0,r2) JUMP(-3) // loop
ADD(1,r3,r3) ADD(0,1,o0) // output size in o0
JUMP(-3) ADD(r0,0,o1) // o1 = a^b = i1^i2
ADD(0,1,o0)
ADD(r2,0,o1)

View File

@ -16,7 +16,7 @@ ADD|SUB|MULT|DIV { yylval = strdup(yytext); return OP;}
JUMP|JE|JL { yylval = strdup(yytext); return OP_CTRL;} JUMP|JE|JL { yylval = strdup(yytext); return OP_CTRL;}
[ ]*,[ ]* {return COMMA;} [ ]*,[ ]* {return COMMA;}
\( {return PAR_O;} \( {return PAR_O;}
\) {return PAR_C;} \)[ ]*("//".*)? {return PAR_C;}
\n {return SEPARATION; } \n {return SEPARATION; }
. {printf("token inconnu\n"); yyterminate();} . {printf("token inconnu\n"); yyterminate();}
%% %%