syntax fix + assembly calculate a^b
This commit is contained in:
parent
2440c7af7b
commit
ee34fc8d14
@ -1,6 +1,13 @@
|
|||||||
LDFLAGS="-L/usr/local/opt/flex/lib"
|
LDFLAGS="-L/usr/local/opt/flex/lib"
|
||||||
|
|
||||||
machine.py: ram
|
a_pow_b: ram
|
||||||
|
./ram < a_pow_b.1
|
||||||
|
echo "### machine.py ###"
|
||||||
|
cat machine.py
|
||||||
|
echo "### execution ###"
|
||||||
|
python machine.py
|
||||||
|
|
||||||
|
test: ram
|
||||||
./ram < test.1
|
./ram < test.1
|
||||||
echo "### machine.py ###"
|
echo "### machine.py ###"
|
||||||
cat machine.py
|
cat machine.py
|
||||||
|
11
src/a_pow_b.1
Normal file
11
src/a_pow_b.1
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
(2,4,5)
|
||||||
|
ADD(i1,0,r0)
|
||||||
|
ADD(i1,0,r1)
|
||||||
|
ADD(i1,0,r2)
|
||||||
|
ADD(1,0,r3)
|
||||||
|
JE(i2,r3,4)
|
||||||
|
MULT(r2,r0,r2)
|
||||||
|
ADD(1,r3,r3)
|
||||||
|
JUMP(-3)
|
||||||
|
ADD(0,1,o0)
|
||||||
|
ADD(r2,0,o1)
|
@ -11,7 +11,7 @@
|
|||||||
%%
|
%%
|
||||||
[rio][0-9]* { yylval = strdup(yytext); return REGISTER;}
|
[rio][0-9]* { yylval = strdup(yytext); return REGISTER;}
|
||||||
[rio]@[rio][0-9]* { yylval = strdup(yytext); return REGISTER_REF;}
|
[rio]@[rio][0-9]* { yylval = strdup(yytext); return REGISTER_REF;}
|
||||||
[0-9]* { yylval = strdup(yytext); return VALUE;}
|
[\-0-9]* { yylval = strdup(yytext); return VALUE;}
|
||||||
ADD|SUB|MULT|DIV { yylval = strdup(yytext); return OP;}
|
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;}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user