http://slps.github.io/zoo/
Sunday, January 5, 2014
Saturday, January 4, 2014
2 Pass Bison Assembler
http://lists.gnu.org/archive/html/help-bison/2009-01/msg00001.html
the simplest assembler sasm cannot handle forward references. We can use single pass but it is too complicated. Inspired by articles such as the above, I attempted 2 pass.
Just add a global variable pass and repeat yyparse().
inside the code generator, if pass = 2, then do the code generation, otherwise just increment PC.
int pass=1;
yyparse();
pass=2;
yyparse;
Alternatively,
just repeat yyparse twice. You will get 2output. just discard the first one.
yyparse();
yyparse();
the simplest assembler sasm cannot handle forward references. We can use single pass but it is too complicated. Inspired by articles such as the above, I attempted 2 pass.
Just add a global variable pass and repeat yyparse().
inside the code generator, if pass = 2, then do the code generation, otherwise just increment PC.
int pass=1;
yyparse();
pass=2;
yyparse;
Alternatively,
just repeat yyparse twice. You will get 2output. just discard the first one.
yyparse();
yyparse();
Subscribe to:
Comments (Atom)