OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [zasm.l] - Diff between revs 16 and 26

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 16 Rev 26
Line 49... Line 49...
%option yylineno
%option yylineno
%option warn
%option warn
 
 
%%
%%
 
 
^"#line"[ \t]+[0-9]+[ \t]+[\"][^"]*[\"][ \t]*$ {
"#line"[ \t]+[0-9]+[ \t]+[\"][^"]*[\"][ \t]*$ {
 
        /* This should really be true *only* at the beginning of a line,
 
        * however such line beginnings aren't matching.  My guess is that
 
        * the reason is my line copying code at the bottom that sucks up the
 
        * newline for LEX.  Hence, this is what we have.
 
        */
                yylineno = atoi(&yytext[6]);
                yylineno = atoi(&yytext[6]);
                char    *bg, *en;
                char    *bg, *en;
                bg = strchr(yytext, '\"')+1;
                bg = strchr(yytext, '\"')+1;
                en = strchr(bg, '\"'); *en = '\0';
                en = strchr(bg, '\"'); *en = '\0';
                if ((master_input_filename == NULL)||(strcmp(master_input_filename, bg)!=0)) {
                if ((master_input_filename == NULL)||(strcmp(master_input_filename, bg)!=0)) {
                        if (!master_input_filename) delete[] master_input_filename;
                        if (!master_input_filename) delete[] master_input_filename;
                        master_input_filename = new char[en-bg+2];
                        master_input_filename = new char[en-bg+2];
                        strcpy(master_input_filename, bg);
                        strcpy(master_input_filename, bg);
                }
                }
 
                return '\n';
                }
                }
^"#line"[ \t]+[0-9]+[ \t]+$     { yylineno = atoi(&yytext[6]); }
"#line"[ \t]+[0-9]+[ \t]*$      { yylineno = atoi(&yytext[6]); return '\n';}
 
^"#line".*$             { printf("WARNING: Unmatched #line: %s\n", yytext); return '\n'; }
 
"#line".*$              { printf("WARNING: Unmatched #line, not at beginnning: %s\n", yytext); return '\n'; }
[uU][rR]1[0-5]  { yylval.u_reg=(ZPARSER::ZIPREG)(26+yytext[3]-'0');return REG; }
[uU][rR]1[0-5]  { yylval.u_reg=(ZPARSER::ZIPREG)(26+yytext[3]-'0');return REG; }
[sS][rR]1[0-5]  { yylval.u_reg=(ZPARSER::ZIPREG)(10+yytext[3]-'0');return REG; }
[sS][rR]1[0-5]  { yylval.u_reg=(ZPARSER::ZIPREG)(10+yytext[3]-'0');return REG; }
[rR]1[0-5]      { yylval.u_reg=(ZPARSER::ZIPREG)(10+yytext[2]-'0');return REG; }
[rR]1[0-5]      { yylval.u_reg=(ZPARSER::ZIPREG)(10+yytext[2]-'0');return REG; }
[uU][rR][0-9]   { yylval.u_reg=(ZPARSER::ZIPREG)(16+yytext[2]-'0');return REG; }
[uU][rR][0-9]   { yylval.u_reg=(ZPARSER::ZIPREG)(16+yytext[2]-'0');return REG; }
[sS][rR][0-9]   { yylval.u_reg=(ZPARSER::ZIPREG)(   yytext[2]-'0');return REG; }
[sS][rR][0-9]   { yylval.u_reg=(ZPARSER::ZIPREG)(   yytext[2]-'0');return REG; }
[rR][0-9]       { yylval.u_reg=(ZPARSER::ZIPREG)(   yytext[1]-'0');return REG; }
[rR][0-9]       { yylval.u_reg=(ZPARSER::ZIPREG)(   yytext[1]-'0');return REG; }
[uU][pP][cC]    { yylval.u_reg = ZPARSER::ZIP_uPC; return REG; }
(?i:upc)        { yylval.u_reg = ZPARSER::ZIP_uPC; return REG; }
[sS][pP][cC]    { yylval.u_reg = ZPARSER::ZIP_PC; return REG; }
(?i:spc)        { yylval.u_reg = ZPARSER::ZIP_PC; return REG; }
[pP][cC]        { yylval.u_reg = ZPARSER::ZIP_PC; return REG; }
(?i:pc)         { yylval.u_reg = ZPARSER::ZIP_PC; return REG; }
[uU][cC][cC]    { yylval.u_reg = ZPARSER::ZIP_uCC; return REG; }
(?i:ucc)        { yylval.u_reg = ZPARSER::ZIP_uCC; return REG; }
[sS][cC][cC]    { yylval.u_reg = ZPARSER::ZIP_CC; return REG; }
(?i:scc)        { yylval.u_reg = ZPARSER::ZIP_CC; return REG; }
[cC][cC]        { yylval.u_reg = ZPARSER::ZIP_CC; return REG; }
(?i:cc)         { yylval.u_reg = ZPARSER::ZIP_CC; return REG; }
[uU][sS][pP]    { yylval.u_reg = ZPARSER::ZIP_uSP; return REG; }
(?i:usp)        { yylval.u_reg = ZPARSER::ZIP_uSP; return REG; }
[sS][sS][pP]    { yylval.u_reg = ZPARSER::ZIP_SP; return REG; }
(?i:ssp)        { yylval.u_reg = ZPARSER::ZIP_SP; return REG; }
[sS][pP]        { yylval.u_reg = ZPARSER::ZIP_SP; return REG; }
(?i:sp)         { yylval.u_reg = ZPARSER::ZIP_SP; return REG; }
[bB][rR][aA]    { yylval.u_op  = OP_BRA; return BRANCHOP; }
[bB][rR][aA]    { yylval.u_op  = OP_BRA; return BRANCHOP; }
[bB][rR][zZ]    { yylval.u_op  = OP_BZ;  return BRANCHOP; }
[bB][rR][zZ]    { yylval.u_op  = OP_BZ;  return BRANCHOP; }
[bB][zZ]        { yylval.u_op  = OP_BZ;  return BRANCHOP; }
[bB][zZ]        { yylval.u_op  = OP_BZ;  return BRANCHOP; }
[bB][nN][zZ]    { yylval.u_op  = OP_BNZ; return BRANCHOP; }
[bB][nN][zZ]    { yylval.u_op  = OP_BNZ; return BRANCHOP; }
[bB][nN][eE]    { yylval.u_op  = OP_BNZ; return BRANCHOP; }
[bB][nN][eE]    { yylval.u_op  = OP_BNZ; return BRANCHOP; }
Line 90... Line 98...
[bB][nN]        { yylval.u_op  = OP_BLT; return BRANCHOP; }
[bB][nN]        { yylval.u_op  = OP_BLT; return BRANCHOP; }
[bB][rR][cC]    { yylval.u_op  = OP_BRC; return BRANCHOP; }
[bB][rR][cC]    { yylval.u_op  = OP_BRC; return BRANCHOP; }
[bB][cC]        { yylval.u_op  = OP_BRC; return BRANCHOP; }
[bB][cC]        { yylval.u_op  = OP_BRC; return BRANCHOP; }
[bB][rR][vV]    { yylval.u_op  = OP_BRV; return BRANCHOP; }
[bB][rR][vV]    { yylval.u_op  = OP_BRV; return BRANCHOP; }
[bB][vV]        { yylval.u_op  = OP_BRV; return BRANCHOP; }
[bB][vV]        { yylval.u_op  = OP_BRV; return BRANCHOP; }
[cC][lL][rR]    { yylval.u_op  = OP_CLR; return SINGLOP; }
(?i:clr)        { yylval.u_op  = OP_CLR; return SINGLOP; }
[cC][lL][rR][fF] {yylval.u_op  = OP_CLRF;return SINGLOP; }
(?i:clrf)       {yylval.u_op  = OP_CLRF;return SINGLOP; }
[iI][nN][tT]    { yylval.u_op  = OP_TRAP;return SINGLOP; }
(?i:int)        { yylval.u_op  = OP_TRAP;return SINGLOP; }
[tT][rR][aA][pP] {yylval.u_op  = OP_TRAP;return SINGLOP; }
(?i:trap)       {yylval.u_op  = OP_TRAP;return SINGLOP; }
[jJ][mM][pP]    { yylval.u_op  = OP_JMP; return SINGLOP; }
(?i:jmp)        { yylval.u_op  = OP_JMP; return SINGLOP; }
[lL][jJ][mM][pP] {yylval.u_op  = OP_LJMP;return SINGLOP; }
[lL][jJ][mM][pP] {yylval.u_op  = OP_LJMP;return SINGLOP; }
[nN][oO][tT]    { yylval.u_op  = OP_NOT; return SINGLOP; }
(?i:neg)        { yylval.u_op  = OP_NEG; return SINGLOP; }
[cC][mM][pP]    { yylval.u_op  = OP_CMP; return DUALOP; }
(?i:not)        { yylval.u_op  = OP_NOT; return SINGLOP; }
[tT][sS][tT]    { yylval.u_op  = OP_TST; return DUALOP; }
(?i:cmp)        { yylval.u_op  = OP_CMP; return DUALOP; }
[mM][oO][vV]    { yylval.u_op  = OP_MOV; return DUALOP; }
(?i:tst)        { yylval.u_op  = OP_TST; return DUALOP; }
[lL][dD][iI]    { yylval.u_op  = OP_LDI; return LDIOP; }
(?i:mov)        { yylval.u_op  = OP_MOV; return DUALOP; }
 
(?i:ldi)        { yylval.u_op  = OP_LDI; return LDIOP; }
[lL][dD][iI][hH][iI]    { yylval.u_op =OP_LDIHI; return LDHLOP; }
[lL][dD][iI][hH][iI]    { yylval.u_op =OP_LDIHI; return LDHLOP; }
[lL][dD][iI][lL][oO]    { yylval.u_op =OP_LDILO; return LDHLOP; }
[lL][dD][iI][lL][oO]    { yylval.u_op =OP_LDILO; return LDHLOP; }
[mM][pP][yY]    { yylval.u_op  = OP_MPY; return DUALOP; }
(?i:mpyu)       { yylval.u_op = OP_MPYU; return DUALOP; }
[rR][oO][lL]    { yylval.u_op  = OP_ROL; return DUALOP; }
(?i:mpys)       { yylval.u_op = OP_MPYS; return DUALOP; }
[sS][uU][bB]    { yylval.u_op  = OP_SUB; return DUALOP; }
(?i:rol)        { yylval.u_op  = OP_ROL; return DUALOP; }
[aA][nN][dD]    { yylval.u_op  = OP_AND; return DUALOP; }
(?i:sub)        { yylval.u_op  = OP_SUB; return DUALOP; }
[aA][dD][dD]    { yylval.u_op  = OP_ADD; return DUALOP; }
(?i:and)        { yylval.u_op  = OP_AND; return DUALOP; }
[oO][rR]        { yylval.u_op  = OP_OR; return DUALOP;; }
(?i:add)        { yylval.u_op  = OP_ADD; return DUALOP; }
[xX][oO][rR]    { yylval.u_op  = OP_XOR; return DUALOP; }
(?i:or)         { yylval.u_op  = OP_OR; return DUALOP;; }
[lL][sS][lL]    { yylval.u_op  = OP_LSL; return DUALOP; }
(?i:xor)        { yylval.u_op  = OP_XOR; return DUALOP; }
[aA][sS][rR]    { yylval.u_op  = OP_ASR; return DUALOP; }
(?i:lsl)        { yylval.u_op  = OP_LSL; return DUALOP; }
[lL][sS][rR]    { yylval.u_op  = OP_LSR; return DUALOP; }
(?i:asr)        { yylval.u_op  = OP_ASR; return DUALOP; }
[lL][oO][dD]            { yylval.u_op = OP_LOD;   return LOADOP; }
(?i:lsr)        { yylval.u_op  = OP_LSR; return DUALOP; }
[sS][tT][oO]            { yylval.u_op = OP_STO;   return STOROP; }
(?i:lod)        { yylval.u_op = OP_LOD;   return LOADOP; }
[hH][aA][lL][tT]        { yylval.u_op = OP_HALT;  return BAREOP;  }
(?i:sto)        { yylval.u_op = OP_STO;   return STOROP; }
[wW][aA][iI][tT]        { yylval.u_op = OP_HALT;  return BAREOP;  }
(?i:halt)       { yylval.u_op = OP_HALT;  return BAREOP;  }
[rR][tT][uU]            { yylval.u_op = OP_RTU;   return BAREOP;  }
(?i:wait)       { yylval.u_op = OP_HALT;  return BAREOP;  }
[nN][oO][pP]            { yylval.u_op = OP_NOOP;  return BAREOP; }
(?i:rtu)        { yylval.u_op = OP_RTU;   return BAREOP;  }
[nN][oO][oO][pP]        { yylval.u_op = OP_NOOP;  return BAREOP; }
(?i:nop)        { yylval.u_op = OP_NOOP;  return BAREOP; }
[bB][rR][eE][aA][kK]    { yylval.u_op = OP_BREAK; return BAREOP; }
(?i:noop)       { yylval.u_op = OP_NOOP;  return BAREOP; }
[bB][rR][kK]            { yylval.u_op = OP_BREAK; return BAREOP; }
(?i:break)      { yylval.u_op = OP_BREAK; return BAREOP; }
[bB][uU][sS][yY]        { yylval.u_op = OP_BUSY;  return BAREOP; }
(?i:brk)        { yylval.u_op = OP_BREAK; return BAREOP; }
[eE][qQ][uU]            { return EQU; }
(?i:busy)       { yylval.u_op = OP_BUSY;  return BAREOP; }
[fF][iI][lL][lL]        { return FILL; }
(?i:equ)        { return EQU; }
[wW][oO][rR][dD]        { return WORD; }
(?i:fill)       { return FILL; }
 
(?i:word)       { return WORD; }
"__"[hH][eE][rR][eE]"__" { return HERE; }
"__"[hH][eE][rR][eE]"__" { return HERE; }
[\.][dD][aA][tT] { return WORD; }
[\.][dD][aA][tT] { return WORD; }
[\.][zZ]/[ \t\n]        { yylval.u_cond = ZPARSER::ZIPC_Z; return COND; }
[\.][zZ]/[ \t\n]        { yylval.u_cond = ZPARSER::ZIPC_Z; return COND; }
[\.][nN][eE]/[ \t\n]    { yylval.u_cond = ZPARSER::ZIPC_NZ; return COND; }
[\.][nN][eE]/[ \t\n]    { yylval.u_cond = ZPARSER::ZIPC_NZ; return COND; }
[\.][nN][zZ]/[ \t\n]    { yylval.u_cond = ZPARSER::ZIPC_NZ; return COND; }
[\.][nN][zZ]/[ \t\n]    { yylval.u_cond = ZPARSER::ZIPC_NZ; return COND; }
Line 143... Line 153...
"$"?[-]?0[xX][0-9A-Fa-f]+ { yylval.u_ival = strtoul(yytext+(((*yytext)=='$')?1:0),NULL,16);return INT;}
"$"?[-]?0[xX][0-9A-Fa-f]+ { yylval.u_ival = strtoul(yytext+(((*yytext)=='$')?1:0),NULL,16);return INT;}
"$"?[-]?0[0-7]+           { yylval.u_ival = strtoul(yytext+(((*yytext)=='$')?1:0),NULL, 8);return INT;}
"$"?[-]?0[0-7]+           { yylval.u_ival = strtoul(yytext+(((*yytext)=='$')?1:0),NULL, 8);return INT;}
"$"?[-]?[1-9][0-9]*       { yylval.u_ival = strtoul(yytext+(((*yytext)=='$')?1:0),NULL,10);return INT;}
"$"?[-]?[1-9][0-9]*       { yylval.u_ival = strtoul(yytext+(((*yytext)=='$')?1:0),NULL,10);return INT;}
"$"?[-]?[1-9A-Fa-f][0-9A-Fa-f]*h {yylval.u_ival=strtoul(yytext+(((*yytext)=='$')?1:0),NULL,16); return INT;}
"$"?[-]?[1-9A-Fa-f][0-9A-Fa-f]*h {yylval.u_ival=strtoul(yytext+(((*yytext)=='$')?1:0),NULL,16); return INT;}
"$"?[-]?[0-7]+o           { yylval.u_ival = strtoul(yytext+(((*yytext)=='$')?1:0),NULL, 8);return INT;}
"$"?[-]?[0-7]+o           { yylval.u_ival = strtoul(yytext+(((*yytext)=='$')?1:0),NULL, 8);return INT;}
 
"\'"[^\\\']"\'"         { printf("Match char, %s\n", yytext); yylval.u_ival = yytext[1]&0x0ff; return INT; }
 
"\'\\"[abnr\\]"\'"              {
 
                yylval.u_ival = yytext[2];
 
                if (yytext[2] == 'a') yylval.u_ival = '\a';
 
                else if (yytext[2] == 'b') yylval.u_ival = '\b';
 
                else if (yytext[2] == 'f') yylval.u_ival = '\f';
 
                else if (yytext[2] == 'n') yylval.u_ival = '\n';
 
                else if (yytext[2] == 'r') yylval.u_ival = '\r';
 
                else if (yytext[2] == 't') yylval.u_ival = '\t';
 
                else if (yytext[2] == 'v') yylval.u_ival = '\v';
 
                else if (yytext[2] == '0') yylval.u_ival = '\0';
 
                else if (yytext[2] == '\\') yylval.u_ival = '\\';
 
                return INT; }
 
"\'"[^\\\'][^\\\']"\'"          { yylval.u_ival = ((yytext[1]&0x0ff)<<8)+(yytext[2]&0x0ff); return INT; }
 
"\'"[^\\\'][^\\\'][^\\\']"\'"           { yylval.u_ival = ((yytext[1]&0x0ff)<<16)
 
                                        +((yytext[2]&0x0ff)<<8)
 
                                        +(yytext[3]&0x0ff); return INT; }
 
"\'"[^\\\'][^\\\'][^\\\'][^\\\']"\'"    { yylval.u_ival = ((yytext[1]&0x0ff)<<24)
 
                                        +((yytext[2]&0x0ff)<<16)
 
                                        +((yytext[3]&0x0ff)<<8)
 
                                        +(yytext[4]&0x0ff); return INT; }
"$"?"0"           { yylval.u_ival = 0;return INT;}
"$"?"0"           { yylval.u_ival = 0;return INT;}
"$"             { return DOLLAR; }
"$"             { return DOLLAR; }
","             { return COMMA; }
","             { return COMMA; }
"+"             { return PLUS; }
"+"             { return PLUS; }
"-"             { return MINUS; }
"-"             { return MINUS; }

powered by: WebSVN 2.1.0

© copyright 1999-2022 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.