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

Subversion Repositories diogenes

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /diogenes/tags/initial/asm
    from Rev 234 to Rev 236
    Reverse comparison

Rev 234 → Rev 236

/.video.asm.swp
0,0 → 1,21
+Ï ‰ h G 6 ì ë ê ² £ a _ ^ 8 Õ +œ +Q +B + + +ù ø Ö Å ¸ ² ± ° ¯ ® nop jump ldi l0, 0x40@ jump to begin of loaded program@@ programm loaded adi l2, 1 @ increase program-write address brnz l4, :1 xor l4, h3, h2 @ check if the instruction writen to pmem is 0xffff stio h3, [l2] @ write instruction to programm-mem or h3, h3, l3 @ merge the two instructionbytes shi l3, 8 @ move received 8 bits2: @ full 16-Bit instruction is ready mov h3, l3 @ h3: holds 16-bit instr (here LSB are set) brnz h1, :1 @ olny first half (LSB) of instruction was received nop @ hier könnte leds echo sein (nop wegen evtl. Simulator bug) brz h1, :2 stio l3, [h0] @ leds echo ldi h0, 0x00 @ leds address stio l3, [h0] @ uart echo (uart should be ready at this point) xor h1, h1, l1 @ toggle state (16 bit Ready) ldio l3, [h0] @ uart rcv ldi h0, 0x81 @ uart data address brz l4, :1 and l4, l3, h0 ldi h0, 2 @ uart data ready bit ldio l3, [l0] ldi l0, 0x80 @ uart status address1: @ wait for byte stio h2, [h1] @ leds echo ldi h1, 0 @ toggle bit (hi low) ldi l1, 1 @ constant 1 lsi h2, 0xff @ h2 = 0xffff ldi h2, 0xff lsi l2, 0x40 @ start of user program ldi l2, 0x8080:@ l4 : temp, used for branch condition@ h2 : holds the bitmask of the invalid instruction 0xffff = special with@ h1 : toggle bit = 0 zero, when a full 16 Bit word was received@ l3 : temp, holds the value received from uart@ l2 : current address for memwrites@ l1 : constant 1@ l0 : temp \ No newline at end of file
.video.asm.swp Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: yacc.tab.in.h =================================================================== --- yacc.tab.in.h (nonexistent) +++ yacc.tab.in.h (revision 236) @@ -0,0 +1,113 @@ +/* A Bison parser, made by GNU Bison 2.2. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + C = 258, + OBRA = 259, + CBRA = 260, + OSBRA = 261, + CSBRA = 262, + NUM = 263, + IMM = 264, + LABEL = 265, + USELAB = 266, + REG = 267, + ARI = 268, + LDI = 269, + LSI = 270, + CMP = 271, + BR = 272, + SHA = 273, + JUMP = 274, + CALL = 275, + MOV = 276, + MEM = 277, + SEL = 278, + SELI = 279, + LDL = 280, + NOP = 281 + }; +#endif +/* Tokens. */ +#define C 258 +#define OBRA 259 +#define CBRA 260 +#define OSBRA 261 +#define CSBRA 262 +#define NUM 263 +#define IMM 264 +#define LABEL 265 +#define USELAB 266 +#define REG 267 +#define ARI 268 +#define LDI 269 +#define LSI 270 +#define CMP 271 +#define BR 272 +#define SHA 273 +#define JUMP 274 +#define CALL 275 +#define MOV 276 +#define MEM 277 +#define SEL 278 +#define SELI 279 +#define LDL 280 +#define NOP 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 55 "yacc.in" +{ + int num; + char *str; +} +/* Line 1528 of yacc.c. */ +#line 106 "yacc.tab.in.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +extern YYSTYPE yylval; +
yacc.tab.in.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: asm =================================================================== --- asm (nonexistent) +++ asm (revision 236) @@ -0,0 +1,204 @@ +ELFàˆ4Äb4 (44€4€  TTT€€°V°V _ ï ïtLž _ ï ïÐÐhhh QåtdRåtd _ ï ïôô€e(/lib/ld-linux.so.2GNU   +  + €+")Œ¬KãÀ8ò‹gUa²4t<H Q`fþI…7ä¹Ûíýám262‰Ì9Æ+¹rË$ƒ)-D–¤4ÓEÀ@_Uö£1ñ– ðäÁ«€ðY„ð__gmon_start__libc.so.6_IO_stdin_usedhcreateexitfopenisalphaputsputcharreallocstdinstrduprewindisatty__errno_locationtoupperclearerrstdoutmallocsscanfstderrfilenofwritefreadatoifprintfhsearch_IO_getc__libc_start_mainferrorfreeGLIBC_2.1GLIBC_2.0ii +ii + ðï€ð„ð ðððð ððððð ð $ð +(ð ,ð 0ð +4ð8ð<ð@ðDðHðLðPðTðXð\ð`ðdðhðU‰åƒìèõèLèw:ÉÃÿ5øïÿ%üïÿ%ðhéàÿÿÿÿ%ðhéÐÿÿÿÿ%ðhéÀÿÿÿÿ% ðhé°ÿÿÿÿ%ðh é ÿÿÿÿ%ðh(éÿÿÿÿ%ðh0é€ÿÿÿÿ%ðh8épÿÿÿÿ% ðh@é`ÿÿÿÿ%$ðhHéPÿÿÿÿ%(ðhPé@ÿÿÿÿ%,ðhXé0ÿÿÿÿ%0ðh`é ÿÿÿÿ%4ðhhéÿÿÿÿ%8ðhpéÿÿÿÿ%<ðhxéðþÿÿÿ%@ðh€éàþÿÿÿ%DðhˆéÐþÿÿÿ%HðhéÀþÿÿÿ%Lðh˜é°þÿÿÿ%Pðh é þÿÿÿ%Tðh¨éþÿÿÿ%Xðh°é€þÿÿÿ%\ðh¸épþÿÿÿ%`ðhÀé`þÿÿÿ%dðhÈéPþÿÿÿ%hðhÐé@þÿÿ1í^‰áƒäðPTRh Áh0ÁQVh³‰è«þÿÿôU‰åSƒìè[Ãäf‹“üÿÿÿ…Òtè6þÿÿX[ÉÃU‰åƒì€=¤ðt ëƒÀ£tðÿÒ¡tð‹…ÒuëƤðÉÃU‰åƒì¡ï…Àt¸…Àt Ç$ïÿÐÉÃU‰åƒì‹€ð‹E‰D$ÇD$‰$è•þÿÿÉÃU‰å¸]ÃL$ƒäðÿqüU‰åWVQƒì,‰Mð‹Eðƒ8ŽŠ‹Uð‹BƒÀ‹‰EìÇEè ÂÇEäü‹uì‹}è‹Mäó¦—Â’ÀˆÑ(ÁˆÈ¾À…Àu +Çäð‹uð‹FƒÀ‹‰EàÇEÜÂÇEØü‹uà‹}Ü‹MØó¦—Â’ÀˆÑ(ÁˆÈ¾À…Àu +Çäðè4…Àu Ç$èXþÿÿ¡äð…Àt(‹uðƒ>u ‹}ð‹GƒÀ‹ÇD$‰$èLýÿÿ£„ð¡äð…Àu(‹Eðƒ8u ‹Uð‹BƒÀ‹ÇD$‰$èýÿÿ£„ðÇxðÇàðè…Àt Ç$èÍýÿÿÇxðÇàð¡„ð‰$è\üÿÿ¡„ð‰$èj3èθƒÄ,Y^_]aüÃU‰åƒì‹E‰Eø‹E ‰Eü‹Eü¶‹Eøˆ‹Eø¶„À•ÀÿEøÿEü„Àuà‹EøHÉÃU‰åWƒì$‹E ¶<"u}ÇEô‹E ‰EøÿEø‹Eø¶¾À‰Eäƒ}ä't[ƒ}ä'ƒ}ä"t8ëƒ}ä,tGƒ}ä\të +ÿEø‹Eø¶<\u2ƒ}t‹Eô‰ÂU‹Eø¶ˆÿEô맃}t ‹EôEÆ‹Eô‰EèëCƒ}u‹E ¹ÿÿÿÿ‰Eà°ü‹}àò®‰È÷ÐH‰Eèë ‹E ‰D$‹E‰$èÿÿÿ‰Â‹E‰Ñ)Á‰È‰Eè‹EèƒÄ$_]ÃU‰åW쨋E ¶€àžÀ‰E¼ƒ}¼ë~ƒ}¼_~Ç…`ÿÿÿéV‹E=w‹E¶€ ¶À‰…dÿÿÿë +Ç…dÿÿÿ‹…dÿÿÿ‰EÀ‹EÀ‹… ĉD$Ç$è¥þÿÿ‰EÄ‹EĉEÈÇEÐÇEàŠÇƒ}¼y‹E¼‰Â÷Ú‰•hÿÿÿë +Ç…hÿÿÿ‹½hÿÿÿ‰}ä¸`+E¼‰E踃}èNEè‰EìÇEð‹EÀ‹… ĉE¨ÇD$™Ç…lÿÿÿ‰$èéýÿÿ‰EØ‹Eä‰EÔé ‹E¼EÔ¶€ÀƶÀ;EÔ…„ƒ}Ôt~ƒ}ðuÇEð‹EĉEÈÆE‡ët‹Uð‹EÔ‹… ĉD•¨ÿEð‹EÔ‹… ĉD$Ç$è­ýÿÿEȉEÌ‹EÌ;EÈ’À¶À EЋẺEÈ‹Eà‰D$‹E؉$èHýÿÿ‰EØÇEàƒÇÿEÔ‹EÔ;EìŒTÿÿÿ…lÿÿÿ‰EÜ‹Eܹÿÿÿÿ‰…\ÿÿÿ°ü‹½\ÿÿÿò®‰È÷ÐHEȉEÌ‹EÌ;EÈ’À¶À EЋẺEȃ}Ðt Ç…`ÿÿÿÿÿÿÿëxƒ}ti‹E‰EôÇEøëE‹Eô¶<%u5‹EÜ@¶?ëë9@@A#ùCBDGýú$IëëëKëëëëLëëEëFHPëRëëëëJMNQUVXTëëëëëëSëYëëë3ëëëëëëëëëëëëìëôë+IBKCL J!$ + +"- + +?N@O.#%&'()*/0123456789,`:=[F;EHQ>RSGTUWVXYB\Z]^_Kba +  + +  +   X /S        + + !"#$%&'()    ++ , -  * .  -*  or %s, expecting %ssyntax error, unexpected %sDeletingwrong sister register2 Bit immediate expectedImmediate syntax8 Bit unsigned immediate expected8 bit signed immediate expectedImmediate Value %d out of range: -32..31 allowed +Immediate Value %d out of range: -32b..31b allowed +syntax errorError: discardingError: poppingmemory exhaustedCleanup: discarding lookaheadCleanup: popping’F’l’’’¸’Þ’“*“P“v“œ““²›è“ø“1”Z”ƒ”Á”•D•x•Ö•ý•1–X–Œ–À–—O—ª— ˜¨™štšÚšF› + + + +    + + +  +  + + + + + + !"#$%&ÂÃ%Ã#&*Ãþ·+ÃÃ,-.4/=3657>TY\ö`»Ã<bGafR´c?gip³qsytz²{}±…‡‚ˆ°©¨¦Š‹Œ¤¡žœ’–•Ã²šµRRRRRRSSTRRUSSRRSSSSSSSSSSSRRSRSSTURSSSSSSSSSSSSSSSSSS"SSSSSSSSSSSSSSSSSSSSSSSSSRRR + +  &,, *',, (+"9)34 0-.12@56 72/ 888 88 > 888882 : ;?A= D <2DE FB C G H 2 #I JLK<N M OM CI P Q Q!!$$$ % %RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR &.&(.+("""")'-""*/+0"""""'13'46)-/*57:3;)633?40=1>@5FGHK5NE7OT:QP=?>;EM@LEGJHFIKDNCBOSSUUUA<92,$! +RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRstopADDSUBANDORXORSHCMPLCMPLSldstldiostiosehsebseibseihseibsseihsfatal flex scanner internal error--no action found1¡T¡`¡l¡x¡„¡¡œ¡ó¡¢W¢u¢­¢‘¤Q¥g¥}¥“¥ï¦Ÿ§û¨©©k©ÞŸÞŸ¥©ß©Ó©fatal flex scanner internal error--end of buffer missedfatal error - scanner input buffer overflowinput in flex scanner failedflex scanner push-back overflowout of dynamic memory in yy_create_buffer()out of dynamic memory in yy_scan_buffer()out of dynamic memory in yy_scan_bytes()bad buffer in yy_scan_bytes()%s +%04x, +,%c%c%x%dÿÿÿÿÿÿÿÿ ‡ +¸ÁˆõþÿoT‚„„„‚ + ôïØ,† † þÿÿoÜ…ÿÿÿoðÿÿoš… ï2‡B‡R‡b‡r‡‚‡’‡¢‡²‡‡Ò‡â‡ò‡ˆˆ"ˆ2ˆBˆRˆbˆrˆ‚ˆ’ˆ¢ˆ²ˆˆÒˆïGCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2)GCC: (GNU) 4.1.2 (Gentoo 4.1.2 p1.0.2).symtab.strtab.shstrtab.interp.note.ABI-tag.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.text.fini.rodata.eh_frame.ctors.dtors.jcr.dynamic.got.got.plt.data.bss.commentTT#hh 5ˆˆÌ1öÿÿoT‚T0; „‚„C„„„Kÿÿÿoš…š@XþÿÿoÜ…Ü0g  †  p ,†,Ø y‡t‡ÀàˆàØ8…¸Á¸A‹àÁàAË “¬Ö¬V ï _¤ï_«ï_° ï _йðïð_¾ôïô_xÇlðl`Í€ð€`Øœ Ò€`hèaÛLgð +O  ÐÔE€ÒÔLHºË +b¶o +wÌð„ØðœÜð³Ð𾩰à +Ô‰±· +åÔ«Õ +øÔðÁ¼/ +#@²y ++¹³ò +1·¶ +@`½Z +PñÿXôïn ï ï’ ï›4­lð ¸ÔHç Á +÷àˆ +þ·z +  2àÁ9`Lþ^¸Ád†¹Â +w½ + +”S½ + + 7³"½ + +À¿. +ʬðйííP½ + +xðäÁ,àð4wÀ¡ +>áNTUlðbô¾ +l«´œ +v½ + +„¾ +ˆ2š@¡¼£ +¯5¸ +¿€ðÑ|¿ +ß/½ + +èäðì2ý»× + ¶¸Ð + ú¼ + +)pð6‰J0ÁZ +Z9lº½ +z+ŠD…¶€ + ’¿M +¬r¾$Ñ€ðñÿ݃ï-ð¼ + +I½ + +„‰% +#¨ð(W¾ +0„ðAj¾ +K6¿F +UXñÿZ ðl©‰ + +s–ƒñ@œŽ<½ + +˜4ªH±|ðº°ðÈEÛLã,Ÿ¨  +é@ú+ +€ðñÿ U£-ê»4 +<ñLGµÏ +`—¾\ +oŠÁ +†³‰ +‹‡ ‘ß¿˜ +y.tab.cyytranslateyytnameyyr1yyr2yydefactyydefgotoyypactyypgotoyytableyycheckyystosyystpcpyyytnamerryyor.2096yyexpecting.2095yyunexpected.2094yysyntax_erroryydestructlex.yy.cyy_buffer_stack_topyy_buffer_stack_maxyy_buffer_stackyy_c_buf_pyy_inityy_startyy_acceptyy_ecyy_metayy_baseyy_defyy_nxtyy_chkyyensure_buffer_stackyy_load_buffer_stateyy_hold_charyy_last_accepting_stateyy_last_accepting_cposyy_n_charsyy_get_previous_stateyy_try_NUL_transyy_get_next_bufferyy_did_buffer_switch_on_eofyy_fatal_erroryyunputinputyy_init_bufferyy_init_globalstools.c_GLOBAL_OFFSET_TABLE___init_array_end__init_array_start_DYNAMICfileno@@GLIBC_2.0data_start__errno_location@@GLIBC_2.0isalpha@@GLIBC_2.0__libc_csu_fini_startyy_delete_buffer__gmon_start___Jv_RegisterClasses_fp_hwrealloc@@GLIBC_2.0rewind@@GLIBC_2.0_finiyypop_buffer_stateyyget_outputchar@@GLIBC_2.0yyset_debugtoupper@@GLIBC_2.0yyset_linenoadd_labelyyout__libc_start_main@@GLIBC_2.0_IO_getc@@GLIBC_2.0yylengyyget_lengfirstpass_IO_stdin_usedaddresscheck_immfree@@GLIBC_2.0yytext__data_starthash_inityyrestartyyget_textyyfreeisatty@@GLIBC_2.0yycharyy_scan_bytesyy_flush_bufferstderr@@GLIBC_2.0get_abs_labelyyset_inhexfopen@@GLIBC_2.1yy_scan_bufferyypush_buffer_stateyyget_in__dso_handleclearerr@@GLIBC_2.0__libc_csu_initprintf@@GLIBC_2.0yylex_destroyatoi@@GLIBC_2.0tempyy_create_bufferstr_toupperfwrite@@GLIBC_2.0fprintf@@GLIBC_2.0__bss_startmalloc@@GLIBC_2.0hcreate@@GLIBC_2.0yyget_linenoyyget_debugyyerroryyinyyallocstdin@@GLIBC_2.0yyreallocget_label_endstdout@@GLIBC_2.0yywrapputs@@GLIBC_2.0addr_tableyyset_outsscanf@@GLIBC_2.0yylvalyylinenoyy_flex_debughsearch@@GLIBC_2.0yynerrsyylexfread@@GLIBC_2.0yyparse_edatastrdup@@GLIBC_2.0ferror@@GLIBC_2.0yy_scan_stringexit@@GLIBC_2.0yy_switch_to_bufferPROC_FLUSH_BUF__i686.get_pc_thunk.bxmain_initxprintf \ No newline at end of file
asm Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: yacc.tab.in =================================================================== --- yacc.tab.in (nonexistent) +++ yacc.tab.in (revision 236) @@ -0,0 +1,1917 @@ +/* A Bison parser, made by GNU Bison 2.2. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.2" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + C = 258, + OBRA = 259, + CBRA = 260, + OSBRA = 261, + CSBRA = 262, + NUM = 263, + IMM = 264, + LABEL = 265, + USELAB = 266, + REG = 267, + ARI = 268, + LDI = 269, + LSI = 270, + CMP = 271, + BR = 272, + SHA = 273, + JUMP = 274, + CALL = 275, + MOV = 276, + MEM = 277, + SEL = 278, + SELI = 279, + LDL = 280, + NOP = 281 + }; +#endif +/* Tokens. */ +#define C 258 +#define OBRA 259 +#define CBRA 260 +#define OSBRA 261 +#define CSBRA 262 +#define NUM 263 +#define IMM 264 +#define LABEL 265 +#define USELAB 266 +#define REG 267 +#define ARI 268 +#define LDI 269 +#define LSI 270 +#define CMP 271 +#define BR 272 +#define SHA 273 +#define JUMP 274 +#define CALL 275 +#define MOV 276 +#define MEM 277 +#define SEL 278 +#define SELI 279 +#define LDL 280 +#define NOP 281 + + + + +/* Copy the first part of user declarations. */ +#line 3 "yacc.in" + + + +#include +#include +#include "tools.h" + +#define YYERROR_VERBOSE + +int temp; +int firstpass=1; + +void yyerror(const char *str) +{ + fprintf(stderr,"error: %s\n",str); +} + +int yywrap() +{ + return 1; +} + +int main(int argc, char **argv) +{ + if(argc>=2) { + if(!strcmp(argv[1], "-h")) hex = 1; + if(!strcmp(argv[1], "-b")) hex = 2; + } + if(!hash_init()) { + exit(1); + printf("could not create hash table\n"); + } + + if(hex && argc==3) stdin = fopen(argv[2], "r"); + if(!hex && argc==2) stdin = fopen(argv[1], "r"); + + firstpass = 1; + address = 0; + if(yyparse()) exit(1); + firstpass = 0; + address = 0; + rewind(stdin); + (void) PROC_FLUSH_BUF (stdin ); + yyparse(); + return 0; +} + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 55 "yacc.in" +{ + int num; + char *str; +} +/* Line 193 of yacc.c. */ +#line 202 "yacc.tab.in" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 215 "yacc.tab.in" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 43 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 95 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 27 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 20 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 40 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 99 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 8, 10, 12, 14, 16, 18, + 20, 22, 24, 26, 28, 30, 32, 34, 36, 43, + 48, 53, 60, 65, 70, 75, 82, 87, 94, 99, + 106, 113, 122, 127, 134, 139, 144, 146, 148, 150, + 152 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 28, 0, -1, 29, -1, 28, 29, -1, 10, -1, + 30, -1, 31, -1, 32, -1, 33, -1, 34, -1, + 35, -1, 36, -1, 37, -1, 38, -1, 39, -1, + 40, -1, 41, -1, 26, -1, 13, 12, 3, 12, + 3, 12, -1, 14, 12, 3, 43, -1, 15, 12, + 3, 43, -1, 16, 12, 3, 12, 3, 12, -1, + 17, 12, 3, 11, -1, 17, 12, 3, 44, -1, + 18, 12, 3, 45, -1, 18, 12, 3, 12, 3, + 45, -1, 19, 6, 12, 7, -1, 20, 12, 3, + 6, 12, 7, -1, 21, 12, 3, 12, -1, 22, + 12, 3, 4, 12, 5, -1, 23, 12, 3, 4, + 12, 5, -1, 23, 12, 3, 12, 3, 4, 12, + 5, -1, 24, 12, 3, 42, -1, 24, 12, 3, + 12, 3, 42, -1, 25, 12, 3, 46, -1, 25, + 12, 3, 11, -1, 9, -1, 9, -1, 9, -1, + 9, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 70, 70, 70, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 82, 83, 84, 89, 91, 93, + 94, 96, 98, 101, 103, 104, 107, 108, 110, 112, + 114, 115, 118, 119, 122, 128, 137, 143, 148, 155, + 161 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "C", "OBRA", "CBRA", "OSBRA", "CSBRA", + "NUM", "IMM", "LABEL", "USELAB", "REG", "ARI", "LDI", "LSI", "CMP", "BR", + "SHA", "JUMP", "CALL", "MOV", "MEM", "SEL", "SELI", "LDL", "NOP", + "$accept", "asms", "asm", "nop", "ari", "ldsi", "cmp", "br", "sha", + "jmpcall", "mov", "mem", "sel", "seli", "ldl", "imm2b", "imm8b", + "imm8bs", "imm6b", "imm32", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 27, 28, 28, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 30, 31, 32, + 32, 33, 34, 34, 35, 35, 36, 36, 37, 38, + 39, 39, 40, 40, 41, 41, 42, 43, 44, 45, + 46 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 6, 4, + 4, 6, 4, 4, 4, 6, 4, 6, 4, 6, + 6, 8, 4, 6, 4, 4, 1, 1, 1, 1, + 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 0, 2, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, + 19, 20, 0, 38, 22, 23, 39, 0, 24, 26, + 0, 28, 0, 0, 0, 36, 0, 32, 40, 35, + 34, 0, 0, 0, 0, 0, 0, 0, 0, 18, + 21, 25, 27, 29, 30, 0, 33, 0, 31 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 77, 60, 65, 68, 80 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -21 +static const yytype_int8 yypact[] = +{ + 17, -21, -8, -5, -4, -1, 16, 37, 6, 38, + 39, 40, 41, 42, 43, -21, 0, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + 26, 45, 53, 54, 55, 56, 48, 58, 59, 60, + 61, 62, 63, -21, -21, 57, 64, 64, 65, 35, + -7, 67, 66, 68, 71, -3, -6, 36, 73, -21, + -21, -21, 75, -21, -21, -21, -21, 76, -21, -21, + 69, -21, 70, 72, 80, -21, 82, -21, -21, -21, + -21, 74, 77, 78, 81, 85, 86, 88, 84, -21, + -21, -21, -21, -21, -21, 83, -21, 89, -21 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -21, -21, 51, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -20, 23, -21, -12, -21 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 43, 73, 66, 75, 30, 67, 76, 31, 32, 74, + 1, 33, 36, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 1, 34, 45, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 63, 78, 64, 79, 46, 35, + 37, 38, 39, 40, 41, 42, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 44, 96, 58, + 61, 91, 70, 59, 69, 72, 81, 62, 82, 83, + 71, 84, 85, 87, 86, 88, 89, 66, 92, 90, + 93, 94, 95, 75, 98, 97 +}; + +static const yytype_uint8 yycheck[] = +{ + 0, 4, 9, 9, 12, 12, 12, 12, 12, 12, + 10, 12, 6, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 10, 12, 3, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 9, 9, 11, 11, 3, 12, + 12, 12, 12, 12, 12, 12, 3, 3, 3, 3, + 12, 3, 3, 3, 3, 3, 3, 16, 88, 12, + 47, 83, 6, 9, 7, 4, 3, 12, 3, 3, + 12, 12, 12, 3, 12, 3, 12, 9, 7, 12, + 5, 5, 4, 9, 5, 12 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 10, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 12, 12, 12, 12, 12, 12, 6, 12, 12, 12, + 12, 12, 12, 0, 29, 3, 3, 3, 3, 3, + 3, 12, 3, 3, 3, 3, 3, 3, 12, 9, + 43, 43, 12, 9, 11, 44, 9, 12, 45, 7, + 6, 12, 4, 4, 12, 9, 12, 42, 9, 11, + 46, 3, 3, 3, 12, 12, 12, 3, 3, 12, + 12, 45, 7, 5, 5, 4, 42, 12, 5 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + const YYSTYPE * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + const YYSTYPE * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, + int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule + ) + YYSTYPE *yyvsp; + + int yyrule; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + +/* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 4: +#line 72 "yacc.in" + {if(firstpass)add_label((yyvsp[(1) - (1)].str), address);;} + break; + + case 5: +#line 73 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 6: +#line 74 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 7: +#line 75 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 8: +#line 76 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 9: +#line 77 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 10: +#line 78 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 11: +#line 79 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 12: +#line 80 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 13: +#line 81 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 14: +#line 82 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 15: +#line 83 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 16: +#line 84 "yacc.in" + {;;} + break; + + case 17: +#line 89 "yacc.in" + { (yyval.num) = (yyvsp[(1) - (1)].num); ;} + break; + + case 18: +#line 91 "yacc.in" + { (yyval.num) = ((yyvsp[(1) - (6)].num)<<12) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(4) - (6)].num)<<4) | (yyvsp[(6) - (6)].num); ;} + break; + + case 19: +#line 93 "yacc.in" + { (yyval.num) = (0x6000) | ((yyvsp[(2) - (4)].num)<<8) | ((yyvsp[(4) - (4)].num)&0xff); ;} + break; + + case 20: +#line 94 "yacc.in" + { (yyval.num) = (0x7000) | ((yyvsp[(2) - (4)].num)<<8) | ((yyvsp[(4) - (4)].num)&0xff); ;} + break; + + case 21: +#line 96 "yacc.in" + { (yyval.num) = (0x8000) | ((yyvsp[(1) - (6)].num)<<12) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(4) - (6)].num)<<4) | (yyvsp[(6) - (6)].num);;} + break; + + case 22: +#line 98 "yacc.in" + { (yyval.num) = (0xc000) | ((yyvsp[(1) - (4)].num)<<12) | (((get_label((yyvsp[(4) - (4)].str))-address)&0xff) << 4) | (yyvsp[(2) - (4)].num); + // if(!firstpass) printf(" @%d - %d: %d", address, $4, get_label($4)); + ;} + break; + + case 23: +#line 101 "yacc.in" + { (yyval.num) = (0xc000) | ((yyvsp[(1) - (4)].num)<<12) | (((yyvsp[(4) - (4)].num)&0xff) << 4) | (yyvsp[(2) - (4)].num); ;} + break; + + case 24: +#line 103 "yacc.in" + { (yyval.num) = (0xe000) | ((yyvsp[(2) - (4)].num)<<8) | ((yyvsp[(1) - (4)].num)<<6) | ((yyvsp[(4) - (4)].num)&0x3f); ;} + break; + + case 25: +#line 104 "yacc.in" + { if(((yyvsp[(2) - (6)].num)^0x8) != (yyvsp[(4) - (6)].num)) { yyerror("wrong sister register"); YYERROR; } + (yyval.num) = (0xe000) | ((yyvsp[(2) - (6)].num)<<8) | (1<<7) | ((yyvsp[(1) - (6)].num)<<6) | ((yyvsp[(6) - (6)].num)&0x3f); ;} + break; + + case 26: +#line 107 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(3) - (4)].num)<<4) | (yyvsp[(1) - (4)].num); ;} + break; + + case 27: +#line 108 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(5) - (6)].num)<<4) | (yyvsp[(1) - (6)].num); ;} + break; + + case 28: +#line 110 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(2) - (4)].num)<<8) | ((yyvsp[(4) - (4)].num)<<4) | 1; ;} + break; + + case 29: +#line 112 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(5) - (6)].num)<<4) | (yyvsp[(1) - (6)].num); ;} + break; + + case 30: +#line 114 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(5) - (6)].num)<<4) | (yyvsp[(1) - (6)].num); ;} + break; + + case 31: +#line 115 "yacc.in" + { if(((yyvsp[(2) - (8)].num)^0x8) != (yyvsp[(4) - (8)].num)) { yyerror("wrong sister register"); YYERROR; } + (yyval.num) = (0xf000) | ((yyvsp[(2) - (8)].num)<<8) | ((yyvsp[(7) - (8)].num)<<4) | (1<<3) | (yyvsp[(1) - (8)].num); ;} + break; + + case 32: +#line 118 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(2) - (4)].num)<<8) | ((yyvsp[(4) - (4)].num)<<6) | (yyvsp[(1) - (4)].num); ;} + break; + + case 33: +#line 119 "yacc.in" + { if(((yyvsp[(2) - (6)].num)^0x8) != (yyvsp[(4) - (6)].num)) { yyerror("wrong sister register"); YYERROR; } + (yyval.num) = (0xf000) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(6) - (6)].num)<<4) | (1<<3) | (yyvsp[(1) - (6)].num); ;} + break; + + case 34: +#line 123 "yacc.in" + { if(!firstpass)xprintf(0x6000|((yyvsp[(2) - (4)].num)<<8)|(((yyvsp[(4) - (4)].num)>>24)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|(((yyvsp[(4) - (4)].num)>>18)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|(((yyvsp[(4) - (4)].num)>>8)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|(((yyvsp[(4) - (4)].num)>>0)&0xff));address++; + ;} + break; + + case 35: +#line 129 "yacc.in" + { temp = get_abs_label((yyvsp[(4) - (4)].str)); + if(!firstpass)xprintf(0x6000|((yyvsp[(2) - (4)].num)<<8)|((temp>>24)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|((temp>>18)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|((temp>>8)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|((temp>>0)&0xff));address++; + ;} + break; + + case 36: +#line 137 "yacc.in" + { + temp = check_imm((yyvsp[(1) - (1)].str), &(yyval.num), 0, 3); + if(temp==1) { yyerror("2 Bit immediate expected"); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ;} + break; + + case 37: +#line 143 "yacc.in" + { + temp = check_imm((yyvsp[(1) - (1)].str), &(yyval.num), 0, 255); + if(temp==1) { yyerror("8 Bit unsigned immediate expected"); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ;} + break; + + case 38: +#line 148 "yacc.in" + { + temp = check_imm((yyvsp[(1) - (1)].str), &(yyval.num), -128, 127); + if(temp==1) { yyerror("8 bit signed immediate expected"); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ;} + break; + + case 39: +#line 155 "yacc.in" + { + temp = check_imm((yyvsp[(1) - (1)].str), &(yyval.num), -32, 31); + if(temp==1) { printf("Immediate Value %d out of range: -32..31 allowed\n", (yyval.num)); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ;} + break; + + case 40: +#line 161 "yacc.in" + { + temp = check_imm((yyvsp[(1) - (1)].str), &(yyval.num), 0x1000000, 0x7fffffff); + if(temp==1) { printf("Immediate Value %d out of range: -32b..31b allowed\n", (yyval.num)); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1703 "yacc.tab.in" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} + + +#line 167 "yacc.in" + +
yacc.tab.in Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: y.tab.c =================================================================== --- y.tab.c (nonexistent) +++ y.tab.c (revision 236) @@ -0,0 +1,1917 @@ +/* A Bison parser, made by GNU Bison 2.2. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.2" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + C = 258, + OBRA = 259, + CBRA = 260, + OSBRA = 261, + CSBRA = 262, + NUM = 263, + IMM = 264, + LABEL = 265, + USELAB = 266, + REG = 267, + ARI = 268, + LDI = 269, + LSI = 270, + CMP = 271, + BR = 272, + SHA = 273, + JUMP = 274, + CALL = 275, + MOV = 276, + MEM = 277, + SEL = 278, + SELI = 279, + LDL = 280, + NOP = 281 + }; +#endif +/* Tokens. */ +#define C 258 +#define OBRA 259 +#define CBRA 260 +#define OSBRA 261 +#define CSBRA 262 +#define NUM 263 +#define IMM 264 +#define LABEL 265 +#define USELAB 266 +#define REG 267 +#define ARI 268 +#define LDI 269 +#define LSI 270 +#define CMP 271 +#define BR 272 +#define SHA 273 +#define JUMP 274 +#define CALL 275 +#define MOV 276 +#define MEM 277 +#define SEL 278 +#define SELI 279 +#define LDL 280 +#define NOP 281 + + + + +/* Copy the first part of user declarations. */ +#line 3 "yacc.in" + + + +#include +#include +#include "tools.h" + +#define YYERROR_VERBOSE + +int temp; +int firstpass=1; + +void yyerror(const char *str) +{ + fprintf(stderr,"error: %s\n",str); +} + +int yywrap() +{ + return 1; +} + +int main(int argc, char **argv) +{ + if(argc>=2) { + if(!strcmp(argv[1], "-h")) hex = 1; + if(!strcmp(argv[1], "-b")) hex = 2; + } + if(!hash_init()) { + exit(1); + printf("could not create hash table\n"); + } + + if(hex && argc==3) stdin = fopen(argv[2], "r"); + if(!hex && argc==2) stdin = fopen(argv[1], "r"); + + firstpass = 1; + address = 0; + if(yyparse()) exit(1); + firstpass = 0; + address = 0; + rewind(stdin); + (void) PROC_FLUSH_BUF (stdin ); + yyparse(); + return 0; +} + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 55 "yacc.in" +{ + int num; + char *str; +} +/* Line 193 of yacc.c. */ +#line 202 "yacc.tab.in" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 215 "yacc.tab.in" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 43 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 95 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 27 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 20 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 40 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 99 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 8, 10, 12, 14, 16, 18, + 20, 22, 24, 26, 28, 30, 32, 34, 36, 43, + 48, 53, 60, 65, 70, 75, 82, 87, 94, 99, + 106, 113, 122, 127, 134, 139, 144, 146, 148, 150, + 152 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 28, 0, -1, 29, -1, 28, 29, -1, 10, -1, + 30, -1, 31, -1, 32, -1, 33, -1, 34, -1, + 35, -1, 36, -1, 37, -1, 38, -1, 39, -1, + 40, -1, 41, -1, 26, -1, 13, 12, 3, 12, + 3, 12, -1, 14, 12, 3, 43, -1, 15, 12, + 3, 43, -1, 16, 12, 3, 12, 3, 12, -1, + 17, 12, 3, 11, -1, 17, 12, 3, 44, -1, + 18, 12, 3, 45, -1, 18, 12, 3, 12, 3, + 45, -1, 19, 6, 12, 7, -1, 20, 12, 3, + 6, 12, 7, -1, 21, 12, 3, 12, -1, 22, + 12, 3, 4, 12, 5, -1, 23, 12, 3, 4, + 12, 5, -1, 23, 12, 3, 12, 3, 4, 12, + 5, -1, 24, 12, 3, 42, -1, 24, 12, 3, + 12, 3, 42, -1, 25, 12, 3, 46, -1, 25, + 12, 3, 11, -1, 9, -1, 9, -1, 9, -1, + 9, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 70, 70, 70, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 82, 83, 84, 89, 91, 93, + 94, 96, 98, 101, 103, 104, 107, 108, 110, 112, + 114, 115, 118, 119, 122, 128, 137, 143, 148, 155, + 161 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "C", "OBRA", "CBRA", "OSBRA", "CSBRA", + "NUM", "IMM", "LABEL", "USELAB", "REG", "ARI", "LDI", "LSI", "CMP", "BR", + "SHA", "JUMP", "CALL", "MOV", "MEM", "SEL", "SELI", "LDL", "NOP", + "$accept", "asms", "asm", "nop", "ari", "ldsi", "cmp", "br", "sha", + "jmpcall", "mov", "mem", "sel", "seli", "ldl", "imm2b", "imm8b", + "imm8bs", "imm6b", "imm32", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 27, 28, 28, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 30, 31, 32, + 32, 33, 34, 34, 35, 35, 36, 36, 37, 38, + 39, 39, 40, 40, 41, 41, 42, 43, 44, 45, + 46 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 6, 4, + 4, 6, 4, 4, 4, 6, 4, 6, 4, 6, + 6, 8, 4, 6, 4, 4, 1, 1, 1, 1, + 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 0, 2, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, + 19, 20, 0, 38, 22, 23, 39, 0, 24, 26, + 0, 28, 0, 0, 0, 36, 0, 32, 40, 35, + 34, 0, 0, 0, 0, 0, 0, 0, 0, 18, + 21, 25, 27, 29, 30, 0, 33, 0, 31 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 77, 60, 65, 68, 80 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -21 +static const yytype_int8 yypact[] = +{ + 17, -21, -8, -5, -4, -1, 16, 37, 6, 38, + 39, 40, 41, 42, 43, -21, 0, -21, -21, -21, + -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, + 26, 45, 53, 54, 55, 56, 48, 58, 59, 60, + 61, 62, 63, -21, -21, 57, 64, 64, 65, 35, + -7, 67, 66, 68, 71, -3, -6, 36, 73, -21, + -21, -21, 75, -21, -21, -21, -21, 76, -21, -21, + 69, -21, 70, 72, 80, -21, 82, -21, -21, -21, + -21, 74, 77, 78, 81, 85, 86, 88, 84, -21, + -21, -21, -21, -21, -21, 83, -21, 89, -21 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -21, -21, 51, -21, -21, -21, -21, -21, -21, -21, + -21, -21, -21, -21, -21, -20, 23, -21, -12, -21 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 43, 73, 66, 75, 30, 67, 76, 31, 32, 74, + 1, 33, 36, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 1, 34, 45, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 63, 78, 64, 79, 46, 35, + 37, 38, 39, 40, 41, 42, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 44, 96, 58, + 61, 91, 70, 59, 69, 72, 81, 62, 82, 83, + 71, 84, 85, 87, 86, 88, 89, 66, 92, 90, + 93, 94, 95, 75, 98, 97 +}; + +static const yytype_uint8 yycheck[] = +{ + 0, 4, 9, 9, 12, 12, 12, 12, 12, 12, + 10, 12, 6, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 10, 12, 3, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 9, 9, 11, 11, 3, 12, + 12, 12, 12, 12, 12, 12, 3, 3, 3, 3, + 12, 3, 3, 3, 3, 3, 3, 16, 88, 12, + 47, 83, 6, 9, 7, 4, 3, 12, 3, 3, + 12, 12, 12, 3, 12, 3, 12, 9, 7, 12, + 5, 5, 4, 9, 5, 12 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 10, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 12, 12, 12, 12, 12, 12, 6, 12, 12, 12, + 12, 12, 12, 0, 29, 3, 3, 3, 3, 3, + 3, 12, 3, 3, 3, 3, 3, 3, 12, 9, + 43, 43, 12, 9, 11, 44, 9, 12, 45, 7, + 6, 12, 4, 4, 12, 9, 12, 42, 9, 11, + 46, 3, 3, 3, 12, 12, 12, 3, 3, 12, + 12, 45, 7, 5, 5, 4, 42, 12, 5 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + const YYSTYPE * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + const YYSTYPE * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, + int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule + ) + YYSTYPE *yyvsp; + + int yyrule; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + +/* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 4: +#line 72 "yacc.in" + {if(firstpass)add_label((yyvsp[(1) - (1)].str), address);;} + break; + + case 5: +#line 73 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 6: +#line 74 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 7: +#line 75 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 8: +#line 76 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 9: +#line 77 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 10: +#line 78 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 11: +#line 79 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 12: +#line 80 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 13: +#line 81 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 14: +#line 82 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 15: +#line 83 "yacc.in" + {if(!firstpass)xprintf((yyvsp[(1) - (1)].num));address++;;} + break; + + case 16: +#line 84 "yacc.in" + {;;} + break; + + case 17: +#line 89 "yacc.in" + { (yyval.num) = (yyvsp[(1) - (1)].num); ;} + break; + + case 18: +#line 91 "yacc.in" + { (yyval.num) = ((yyvsp[(1) - (6)].num)<<12) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(4) - (6)].num)<<4) | (yyvsp[(6) - (6)].num); ;} + break; + + case 19: +#line 93 "yacc.in" + { (yyval.num) = (0x6000) | ((yyvsp[(2) - (4)].num)<<8) | ((yyvsp[(4) - (4)].num)&0xff); ;} + break; + + case 20: +#line 94 "yacc.in" + { (yyval.num) = (0x7000) | ((yyvsp[(2) - (4)].num)<<8) | ((yyvsp[(4) - (4)].num)&0xff); ;} + break; + + case 21: +#line 96 "yacc.in" + { (yyval.num) = (0x8000) | ((yyvsp[(1) - (6)].num)<<12) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(4) - (6)].num)<<4) | (yyvsp[(6) - (6)].num);;} + break; + + case 22: +#line 98 "yacc.in" + { (yyval.num) = (0xc000) | ((yyvsp[(1) - (4)].num)<<12) | (((get_label((yyvsp[(4) - (4)].str))-address)&0xff) << 4) | (yyvsp[(2) - (4)].num); + // if(!firstpass) printf(" @%d - %d: %d", address, $4, get_label($4)); + ;} + break; + + case 23: +#line 101 "yacc.in" + { (yyval.num) = (0xc000) | ((yyvsp[(1) - (4)].num)<<12) | (((yyvsp[(4) - (4)].num)&0xff) << 4) | (yyvsp[(2) - (4)].num); ;} + break; + + case 24: +#line 103 "yacc.in" + { (yyval.num) = (0xe000) | ((yyvsp[(2) - (4)].num)<<8) | ((yyvsp[(1) - (4)].num)<<6) | ((yyvsp[(4) - (4)].num)&0x3f); ;} + break; + + case 25: +#line 104 "yacc.in" + { if(((yyvsp[(2) - (6)].num)^0x8) != (yyvsp[(4) - (6)].num)) { yyerror("wrong sister register"); YYERROR; } + (yyval.num) = (0xe000) | ((yyvsp[(2) - (6)].num)<<8) | (1<<7) | ((yyvsp[(1) - (6)].num)<<6) | ((yyvsp[(6) - (6)].num)&0x3f); ;} + break; + + case 26: +#line 107 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(3) - (4)].num)<<4) | (yyvsp[(1) - (4)].num); ;} + break; + + case 27: +#line 108 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(5) - (6)].num)<<4) | (yyvsp[(1) - (6)].num); ;} + break; + + case 28: +#line 110 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(2) - (4)].num)<<8) | ((yyvsp[(4) - (4)].num)<<4) | 1; ;} + break; + + case 29: +#line 112 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(5) - (6)].num)<<4) | (yyvsp[(1) - (6)].num); ;} + break; + + case 30: +#line 114 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(5) - (6)].num)<<4) | (yyvsp[(1) - (6)].num); ;} + break; + + case 31: +#line 115 "yacc.in" + { if(((yyvsp[(2) - (8)].num)^0x8) != (yyvsp[(4) - (8)].num)) { yyerror("wrong sister register"); YYERROR; } + (yyval.num) = (0xf000) | ((yyvsp[(2) - (8)].num)<<8) | ((yyvsp[(7) - (8)].num)<<4) | (1<<3) | (yyvsp[(1) - (8)].num); ;} + break; + + case 32: +#line 118 "yacc.in" + { (yyval.num) = (0xf000) | ((yyvsp[(2) - (4)].num)<<8) | ((yyvsp[(4) - (4)].num)<<6) | (yyvsp[(1) - (4)].num); ;} + break; + + case 33: +#line 119 "yacc.in" + { if(((yyvsp[(2) - (6)].num)^0x8) != (yyvsp[(4) - (6)].num)) { yyerror("wrong sister register"); YYERROR; } + (yyval.num) = (0xf000) | ((yyvsp[(2) - (6)].num)<<8) | ((yyvsp[(6) - (6)].num)<<4) | (1<<3) | (yyvsp[(1) - (6)].num); ;} + break; + + case 34: +#line 123 "yacc.in" + { if(!firstpass)xprintf(0x6000|((yyvsp[(2) - (4)].num)<<8)|(((yyvsp[(4) - (4)].num)>>24)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|(((yyvsp[(4) - (4)].num)>>18)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|(((yyvsp[(4) - (4)].num)>>8)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|(((yyvsp[(4) - (4)].num)>>0)&0xff));address++; + ;} + break; + + case 35: +#line 129 "yacc.in" + { temp = get_abs_label((yyvsp[(4) - (4)].str)); + if(!firstpass)xprintf(0x6000|((yyvsp[(2) - (4)].num)<<8)|((temp>>24)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|((temp>>18)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|((temp>>8)&0xff));address++; + if(!firstpass)xprintf(0x7000|((yyvsp[(2) - (4)].num)<<8)|((temp>>0)&0xff));address++; + ;} + break; + + case 36: +#line 137 "yacc.in" + { + temp = check_imm((yyvsp[(1) - (1)].str), &(yyval.num), 0, 3); + if(temp==1) { yyerror("2 Bit immediate expected"); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ;} + break; + + case 37: +#line 143 "yacc.in" + { + temp = check_imm((yyvsp[(1) - (1)].str), &(yyval.num), 0, 255); + if(temp==1) { yyerror("8 Bit unsigned immediate expected"); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ;} + break; + + case 38: +#line 148 "yacc.in" + { + temp = check_imm((yyvsp[(1) - (1)].str), &(yyval.num), -128, 127); + if(temp==1) { yyerror("8 bit signed immediate expected"); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ;} + break; + + case 39: +#line 155 "yacc.in" + { + temp = check_imm((yyvsp[(1) - (1)].str), &(yyval.num), -32, 31); + if(temp==1) { printf("Immediate Value %d out of range: -32..31 allowed\n", (yyval.num)); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ;} + break; + + case 40: +#line 161 "yacc.in" + { + temp = check_imm((yyvsp[(1) - (1)].str), &(yyval.num), 0x1000000, 0x7fffffff); + if(temp==1) { printf("Immediate Value %d out of range: -32b..31b allowed\n", (yyval.num)); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1703 "yacc.tab.in" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} + + +#line 167 "yacc.in" + +
y.tab.c Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: y.tab.h =================================================================== --- y.tab.h (nonexistent) +++ y.tab.h (revision 236) @@ -0,0 +1,113 @@ +/* A Bison parser, made by GNU Bison 2.2. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + C = 258, + OBRA = 259, + CBRA = 260, + OSBRA = 261, + CSBRA = 262, + NUM = 263, + IMM = 264, + LABEL = 265, + USELAB = 266, + REG = 267, + ARI = 268, + LDI = 269, + LSI = 270, + CMP = 271, + BR = 272, + SHA = 273, + JUMP = 274, + CALL = 275, + MOV = 276, + MEM = 277, + SEL = 278, + SELI = 279, + LDL = 280, + NOP = 281 + }; +#endif +/* Tokens. */ +#define C 258 +#define OBRA 259 +#define CBRA 260 +#define OSBRA 261 +#define CSBRA 262 +#define NUM 263 +#define IMM 264 +#define LABEL 265 +#define USELAB 266 +#define REG 267 +#define ARI 268 +#define LDI 269 +#define LSI 270 +#define CMP 271 +#define BR 272 +#define SHA 273 +#define JUMP 274 +#define CALL 275 +#define MOV 276 +#define MEM 277 +#define SEL 278 +#define SELI 279 +#define LDL 280 +#define NOP 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 55 "yacc.in" +{ + int num; + char *str; +} +/* Line 1528 of yacc.c. */ +#line 106 "yacc.tab.in.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +extern YYSTYPE yylval; +
y.tab.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: lex.yy.c =================================================================== --- lex.yy.c (nonexistent) +++ lex.yy.c (revision 236) @@ -0,0 +1,1976 @@ + +#line 3 "lex.yy.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 33 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart(yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int yyleng; + +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef unsigned int yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart (FILE *input_file ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); +void yy_delete_buffer (YY_BUFFER_STATE b ); +void yy_flush_buffer (YY_BUFFER_STATE b ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state (void ); + +static void yyensure_buffer_stack (void ); +static void yy_load_buffer_state (void ); +static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); + +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define yywrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; + +typedef int yy_state_type; + +extern int yylineno; + +int yylineno = 1; + +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 26 +#define YY_END_OF_BUFFER 27 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[83] = + { 0, + 0, 0, 27, 26, 25, 1, 26, 10, 10, 26, + 4, 5, 26, 26, 26, 2, 3, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 25, 10, + 10, 9, 0, 0, 8, 0, 24, 0, 0, 0, + 0, 0, 0, 11, 0, 17, 0, 0, 0, 12, + 0, 12, 17, 0, 0, 10, 6, 23, 0, 22, + 0, 0, 0, 20, 21, 16, 7, 18, 0, 23, + 0, 0, 23, 15, 13, 14, 17, 19, 19, 13, + 19, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 4, 5, 1, 1, 6, 7, 7, + 7, 7, 7, 7, 7, 8, 8, 9, 1, 10, + 1, 11, 1, 12, 13, 13, 13, 14, 13, 13, + 15, 15, 15, 15, 15, 16, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 17, 1, 18, 1, 15, 1, 19, 20, 21, 22, + + 23, 13, 15, 24, 25, 26, 15, 27, 28, 29, + 30, 31, 15, 32, 33, 34, 35, 36, 15, 37, + 15, 38, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[39] = + { 0, + 1, 1, 1, 1, 1, 2, 2, 2, 3, 1, + 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2 + } ; + +static yyconst flex_int16_t yy_base[86] = + { 0, + 0, 0, 194, 195, 37, 195, 35, 38, 42, 0, + 195, 195, 190, 183, 43, 195, 195, 44, 45, 46, + 52, 47, 61, 51, 54, 53, 55, 62, 84, 89, + 92, 195, 182, 96, 0, 187, 195, 60, 98, 71, + 97, 102, 82, 180, 99, 63, 103, 105, 112, 179, + 113, 115, 121, 116, 122, 0, 178, 123, 125, 177, + 133, 135, 130, 136, 176, 169, 168, 166, 144, 138, + 139, 140, 164, 161, 141, 158, 156, 143, 146, 150, + 149, 195, 178, 154, 181 + } ; + +static yyconst flex_int16_t yy_def[86] = + { 0, + 82, 1, 82, 82, 82, 82, 82, 83, 83, 84, + 82, 82, 85, 83, 83, 82, 82, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 82, 82, + 83, 82, 83, 83, 84, 85, 82, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 34, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, + 83, 0, 82, 82, 82 + } ; + +static yyconst flex_int16_t yy_nxt[234] = + { 0, + 4, 5, 5, 6, 7, 8, 9, 9, 10, 11, + 12, 13, 14, 14, 14, 15, 16, 17, 18, 19, + 20, 14, 14, 21, 14, 22, 23, 24, 25, 26, + 14, 14, 27, 14, 14, 14, 28, 14, 29, 29, + 30, 30, 30, 31, 31, 31, 32, 31, 31, 31, + 32, 32, 32, 32, 32, 32, 38, 44, 44, 32, + 32, 32, 32, 32, 42, 39, 44, 44, 32, 32, + 32, 32, 40, 43, 34, 57, 41, 51, 52, 32, + 48, 45, 46, 49, 50, 29, 29, 64, 53, 54, + 32, 55, 50, 47, 30, 30, 30, 31, 31, 31, + + 32, 56, 56, 56, 32, 32, 32, 32, 56, 56, + 32, 32, 62, 32, 56, 56, 56, 56, 56, 50, + 32, 32, 58, 32, 32, 59, 63, 65, 61, 32, + 32, 32, 68, 32, 60, 50, 68, 69, 32, 70, + 66, 32, 67, 32, 32, 71, 32, 32, 32, 32, + 72, 32, 32, 50, 32, 35, 73, 32, 32, 74, + 76, 75, 60, 78, 32, 77, 32, 79, 77, 32, + 67, 73, 32, 80, 32, 81, 32, 32, 81, 33, + 33, 36, 36, 36, 32, 32, 32, 32, 32, 37, + 32, 32, 37, 82, 3, 82, 82, 82, 82, 82, + + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82 + } ; + +static yyconst flex_int16_t yy_chk[234] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, + 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, + 9, 15, 18, 19, 20, 22, 15, 21, 21, 24, + 21, 26, 25, 27, 20, 18, 23, 23, 38, 23, + 28, 46, 18, 20, 8, 38, 19, 27, 27, 40, + 24, 22, 23, 25, 26, 29, 29, 46, 27, 27, + 43, 28, 40, 23, 30, 30, 30, 31, 31, 31, + + 31, 34, 34, 34, 34, 41, 39, 45, 34, 34, + 42, 47, 43, 48, 34, 34, 34, 34, 34, 39, + 49, 51, 39, 52, 54, 41, 45, 47, 42, 53, + 55, 58, 51, 59, 41, 54, 51, 51, 63, 52, + 48, 61, 49, 62, 64, 53, 70, 71, 72, 75, + 53, 78, 69, 55, 79, 84, 58, 81, 80, 61, + 63, 62, 59, 69, 77, 64, 76, 69, 71, 74, + 72, 70, 73, 75, 68, 78, 67, 66, 79, 83, + 83, 85, 85, 85, 65, 60, 57, 50, 44, 36, + 33, 14, 13, 3, 82, 82, 82, 82, 82, 82, + + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, + 82, 82, 82 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int yy_flex_debug; +int yy_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "lex.in" +#line 4 "lex.in" + +#include +#include +#include "tools.h" + +#include "y.tab.h" + +#line 541 "lex.yy.c" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap (void ); +#else +extern int yywrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 43 "lex.in" + +#line 696 "lex.yy.c" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 83 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 195 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 44 "lex.in" +{return C;} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 45 "lex.in" +{return OBRA;} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 46 "lex.in" +{return CBRA;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 47 "lex.in" +{return OSBRA;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 48 "lex.in" +{return CSBRA;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 49 "lex.in" +{return LDL;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 50 "lex.in" +{ if (!strcmp(yytext, "stop")) yylval.num=0xffff; + else yylval.num = 0xe000; + return NOP; + } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 54 "lex.in" +{yylval.str=strdup(yytext+1); return USELAB;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 55 "lex.in" +{yylval.str=strdup(yytext); yylval.str[strlen(yytext)-1] = 0; return LABEL;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 56 "lex.in" +{ + //if(yytext[0]=='\'') { + // yytext[strlen(yytext)-1]=' '; + //} + //yytext[0] = ' '; + yylval.str = (char *) strdup(yytext); + return IMM;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 63 "lex.in" +{ + //yylval.str=strdup(yytext); + yylval.num=atoi(yytext+1); + if(yytext[0]=='h') yylval.num+=8; + return REG;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 69 "lex.in" +{ + if(!strcmp(str_toupper(yytext),"ADD")) yylval.num=0x00; + else if(!strcmp(str_toupper(yytext),"SUB")) yylval.num=0x01; + else if(!strcmp(str_toupper(yytext),"AND")) yylval.num=0x02; + else if(!strcmp(str_toupper(yytext),"OR")) yylval.num=0x03; + else if(!strcmp(str_toupper(yytext),"XOR")) yylval.num=0x04; + else if(!strcmp(str_toupper(yytext),"SH")) yylval.num=0x05; + + return ARI; + } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 79 "lex.in" +{ + if(!strcmp(str_toupper(yytext),"CMPL")) yylval.num=0x00; + else if(!strcmp(str_toupper(yytext),"CMPLS")) yylval.num=0x01; + //else if(!strcmp(str_toupper(yytext),"CMPG")) yylval.num=0x02; + //else if(!strcmp(str_toupper(yytext),"CMPGS")) yylval.num=0x03; + return CMP; + } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 86 "lex.in" +{ yylval.num=0; return JUMP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 87 "lex.in" +{ yylval.num=8; return CALL; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 88 "lex.in" +{ yylval.num=1; return MOV; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 89 "lex.in" +{ + if(!strcmp(yytext,"ld")) yylval.num=2; + else if(!strcmp(yytext,"st")) yylval.num=3; + else if(!strcmp(yytext,"ldio")) yylval.num=10; + else if(!strcmp(yytext,"stio")) yylval.num=11; + return MEM; + } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 96 "lex.in" +{ + if(!strcmp(yytext,"seh")) yylval.num=4; + else if(!strcmp(yytext,"seb")) yylval.num=5; + return SEL; + } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 101 "lex.in" +{ + if(!strcmp(yytext,"seib")) yylval.num=0x06; + else if(!strcmp(yytext,"seih")) yylval.num=0x16; + else if(!strcmp(yytext,"seibs")) yylval.num=0x26; + else if(!strcmp(yytext,"seihs")) yylval.num=0x36; + return SELI; + } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 108 "lex.in" +{ + return LDI; + } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 111 "lex.in" +{ + return LSI; + } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 114 "lex.in" +{ + if(toupper(yytext[2])=='N') yylval.num = 1; + else if(toupper(yytext[2])=='Z') yylval.num = 0; + return BR; + } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 119 "lex.in" +{ + if(toupper(yytext[0])=='A') yylval.num = 0; + else yylval.num = 1; + return SHA; + } + YY_BREAK +case 24: +/* rule 24 can match eol */ +YY_RULE_SETUP +#line 124 "lex.in" +/* remove comment */ + YY_BREAK +case 25: +/* rule 25 can match eol */ +YY_RULE_SETUP +#line 125 "lex.in" +/* remove ws */ + YY_BREAK +case 26: +YY_RULE_SETUP +#line 127 "lex.in" +ECHO; + YY_BREAK +#line 967 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart(yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 83 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 83 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 82); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart(yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); + } + + yy_init_buffer(YY_CURRENT_BUFFER,input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree((void *) b->yy_ch_buf ); + + yyfree((void *) b ); +} + +#ifndef _UNISTD_H /* assume unistd.h has isatty() for us */ +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __THROW /* this is a gnuism */ +extern int isatty (int ) __THROW; +#else +extern int isatty (int ); +#endif +#ifdef __cplusplus +} +#endif +#endif + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + yy_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param str a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) +{ + + return yy_scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) yyalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} + +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} + +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} + +/** Get the length of the current token. + * + */ +int yyget_leng (void) +{ + return yyleng; +} + +/** Get the current token. + * + */ + +char *yyget_text (void) +{ + return yytext; +} + +/** Set the current line number. + * @param line_number + * + */ +void yyset_lineno (int line_number ) +{ + + yylineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * in_str ) +{ + yyin = in_str ; +} + +void yyset_out (FILE * out_str ) +{ + yyout = out_str ; +} + +int yyget_debug (void) +{ + return yy_flex_debug; +} + +void yyset_debug (int bdebug ) +{ + yy_flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 127 "lex.in" + + + +void PROC_FLUSH_BUF ( FILE * xFile ) +{ + yy_delete_buffer ( YY_CURRENT_BUFFER ); + yy_init_globals(); + yy_switch_to_buffer ( yy_create_buffer ( xFile, YY_BUF_SIZE ) ); +} + + +//void main() { while(yylex()); } + +
lex.yy.c Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: yacc.output =================================================================== --- yacc.output (nonexistent) +++ yacc.output (revision 236) @@ -0,0 +1,928 @@ +Terminals which are not used + + NUM + + +Grammar + + 0 $accept: asms $end + + 1 asms: asm + 2 | asms asm + + 3 asm: LABEL + 4 | nop + 5 | ari + 6 | ldsi + 7 | cmp + 8 | br + 9 | sha + 10 | jmpcall + 11 | mov + 12 | mem + 13 | sel + 14 | seli + 15 | ldl + + 16 nop: NOP + + 17 ari: ARI REG C REG C REG + + 18 ldsi: LDI REG C imm8b + 19 | LSI REG C imm8b + + 20 cmp: CMP REG C REG C REG + + 21 br: BR REG C USELAB + 22 | BR REG C imm8bs + + 23 sha: SHA REG C imm6b + 24 | SHA REG C REG C imm6b + + 25 jmpcall: JUMP OSBRA REG CSBRA + 26 | CALL REG C OSBRA REG CSBRA + + 27 mov: MOV REG C REG + + 28 mem: MEM REG C OBRA REG CBRA + + 29 sel: SEL REG C OBRA REG CBRA + 30 | SEL REG C REG C OBRA REG CBRA + + 31 seli: SELI REG C imm2b + 32 | SELI REG C REG C imm2b + + 33 ldl: LDL REG C imm32 + 34 | LDL REG C USELAB + + 35 imm2b: IMM + + 36 imm8b: IMM + + 37 imm8bs: IMM + + 38 imm6b: IMM + + 39 imm32: IMM + + +Terminals, with rules where they appear + +$end (0) 0 +error (256) +C (258) 17 18 19 20 21 22 23 24 26 27 28 29 30 31 32 33 34 +OBRA (259) 28 29 30 +CBRA (260) 28 29 30 +OSBRA (261) 25 26 +CSBRA (262) 25 26 +NUM (263) +IMM (264) 35 36 37 38 39 +LABEL (265) 3 +USELAB (266) 21 34 +REG (267) 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 +ARI (268) 17 +LDI (269) 18 +LSI (270) 19 +CMP (271) 20 +BR (272) 21 22 +SHA (273) 23 24 +JUMP (274) 25 +CALL (275) 26 +MOV (276) 27 +MEM (277) 28 +SEL (278) 29 30 +SELI (279) 31 32 +LDL (280) 33 34 +NOP (281) 16 + + +Nonterminals, with rules where they appear + +$accept (27) + on left: 0 +asms (28) + on left: 1 2, on right: 0 2 +asm (29) + on left: 3 4 5 6 7 8 9 10 11 12 13 14 15, on right: 1 2 +nop (30) + on left: 16, on right: 4 +ari (31) + on left: 17, on right: 5 +ldsi (32) + on left: 18 19, on right: 6 +cmp (33) + on left: 20, on right: 7 +br (34) + on left: 21 22, on right: 8 +sha (35) + on left: 23 24, on right: 9 +jmpcall (36) + on left: 25 26, on right: 10 +mov (37) + on left: 27, on right: 11 +mem (38) + on left: 28, on right: 12 +sel (39) + on left: 29 30, on right: 13 +seli (40) + on left: 31 32, on right: 14 +ldl (41) + on left: 33 34, on right: 15 +imm2b (42) + on left: 35, on right: 31 32 +imm8b (43) + on left: 36, on right: 18 19 +imm8bs (44) + on left: 37, on right: 22 +imm6b (45) + on left: 38, on right: 23 24 +imm32 (46) + on left: 39, on right: 33 + + +state 0 + + 0 $accept: . asms $end + + LABEL shift, and go to state 1 + ARI shift, and go to state 2 + LDI shift, and go to state 3 + LSI shift, and go to state 4 + CMP shift, and go to state 5 + BR shift, and go to state 6 + SHA shift, and go to state 7 + JUMP shift, and go to state 8 + CALL shift, and go to state 9 + MOV shift, and go to state 10 + MEM shift, and go to state 11 + SEL shift, and go to state 12 + SELI shift, and go to state 13 + LDL shift, and go to state 14 + NOP shift, and go to state 15 + + asms go to state 16 + asm go to state 17 + nop go to state 18 + ari go to state 19 + ldsi go to state 20 + cmp go to state 21 + br go to state 22 + sha go to state 23 + jmpcall go to state 24 + mov go to state 25 + mem go to state 26 + sel go to state 27 + seli go to state 28 + ldl go to state 29 + + +state 1 + + 3 asm: LABEL . + + $default reduce using rule 3 (asm) + + +state 2 + + 17 ari: ARI . REG C REG C REG + + REG shift, and go to state 30 + + +state 3 + + 18 ldsi: LDI . REG C imm8b + + REG shift, and go to state 31 + + +state 4 + + 19 ldsi: LSI . REG C imm8b + + REG shift, and go to state 32 + + +state 5 + + 20 cmp: CMP . REG C REG C REG + + REG shift, and go to state 33 + + +state 6 + + 21 br: BR . REG C USELAB + 22 | BR . REG C imm8bs + + REG shift, and go to state 34 + + +state 7 + + 23 sha: SHA . REG C imm6b + 24 | SHA . REG C REG C imm6b + + REG shift, and go to state 35 + + +state 8 + + 25 jmpcall: JUMP . OSBRA REG CSBRA + + OSBRA shift, and go to state 36 + + +state 9 + + 26 jmpcall: CALL . REG C OSBRA REG CSBRA + + REG shift, and go to state 37 + + +state 10 + + 27 mov: MOV . REG C REG + + REG shift, and go to state 38 + + +state 11 + + 28 mem: MEM . REG C OBRA REG CBRA + + REG shift, and go to state 39 + + +state 12 + + 29 sel: SEL . REG C OBRA REG CBRA + 30 | SEL . REG C REG C OBRA REG CBRA + + REG shift, and go to state 40 + + +state 13 + + 31 seli: SELI . REG C imm2b + 32 | SELI . REG C REG C imm2b + + REG shift, and go to state 41 + + +state 14 + + 33 ldl: LDL . REG C imm32 + 34 | LDL . REG C USELAB + + REG shift, and go to state 42 + + +state 15 + + 16 nop: NOP . + + $default reduce using rule 16 (nop) + + +state 16 + + 0 $accept: asms . $end + 2 asms: asms . asm + + $end shift, and go to state 43 + LABEL shift, and go to state 1 + ARI shift, and go to state 2 + LDI shift, and go to state 3 + LSI shift, and go to state 4 + CMP shift, and go to state 5 + BR shift, and go to state 6 + SHA shift, and go to state 7 + JUMP shift, and go to state 8 + CALL shift, and go to state 9 + MOV shift, and go to state 10 + MEM shift, and go to state 11 + SEL shift, and go to state 12 + SELI shift, and go to state 13 + LDL shift, and go to state 14 + NOP shift, and go to state 15 + + asm go to state 44 + nop go to state 18 + ari go to state 19 + ldsi go to state 20 + cmp go to state 21 + br go to state 22 + sha go to state 23 + jmpcall go to state 24 + mov go to state 25 + mem go to state 26 + sel go to state 27 + seli go to state 28 + ldl go to state 29 + + +state 17 + + 1 asms: asm . + + $default reduce using rule 1 (asms) + + +state 18 + + 4 asm: nop . + + $default reduce using rule 4 (asm) + + +state 19 + + 5 asm: ari . + + $default reduce using rule 5 (asm) + + +state 20 + + 6 asm: ldsi . + + $default reduce using rule 6 (asm) + + +state 21 + + 7 asm: cmp . + + $default reduce using rule 7 (asm) + + +state 22 + + 8 asm: br . + + $default reduce using rule 8 (asm) + + +state 23 + + 9 asm: sha . + + $default reduce using rule 9 (asm) + + +state 24 + + 10 asm: jmpcall . + + $default reduce using rule 10 (asm) + + +state 25 + + 11 asm: mov . + + $default reduce using rule 11 (asm) + + +state 26 + + 12 asm: mem . + + $default reduce using rule 12 (asm) + + +state 27 + + 13 asm: sel . + + $default reduce using rule 13 (asm) + + +state 28 + + 14 asm: seli . + + $default reduce using rule 14 (asm) + + +state 29 + + 15 asm: ldl . + + $default reduce using rule 15 (asm) + + +state 30 + + 17 ari: ARI REG . C REG C REG + + C shift, and go to state 45 + + +state 31 + + 18 ldsi: LDI REG . C imm8b + + C shift, and go to state 46 + + +state 32 + + 19 ldsi: LSI REG . C imm8b + + C shift, and go to state 47 + + +state 33 + + 20 cmp: CMP REG . C REG C REG + + C shift, and go to state 48 + + +state 34 + + 21 br: BR REG . C USELAB + 22 | BR REG . C imm8bs + + C shift, and go to state 49 + + +state 35 + + 23 sha: SHA REG . C imm6b + 24 | SHA REG . C REG C imm6b + + C shift, and go to state 50 + + +state 36 + + 25 jmpcall: JUMP OSBRA . REG CSBRA + + REG shift, and go to state 51 + + +state 37 + + 26 jmpcall: CALL REG . C OSBRA REG CSBRA + + C shift, and go to state 52 + + +state 38 + + 27 mov: MOV REG . C REG + + C shift, and go to state 53 + + +state 39 + + 28 mem: MEM REG . C OBRA REG CBRA + + C shift, and go to state 54 + + +state 40 + + 29 sel: SEL REG . C OBRA REG CBRA + 30 | SEL REG . C REG C OBRA REG CBRA + + C shift, and go to state 55 + + +state 41 + + 31 seli: SELI REG . C imm2b + 32 | SELI REG . C REG C imm2b + + C shift, and go to state 56 + + +state 42 + + 33 ldl: LDL REG . C imm32 + 34 | LDL REG . C USELAB + + C shift, and go to state 57 + + +state 43 + + 0 $accept: asms $end . + + $default accept + + +state 44 + + 2 asms: asms asm . + + $default reduce using rule 2 (asms) + + +state 45 + + 17 ari: ARI REG C . REG C REG + + REG shift, and go to state 58 + + +state 46 + + 18 ldsi: LDI REG C . imm8b + + IMM shift, and go to state 59 + + imm8b go to state 60 + + +state 47 + + 19 ldsi: LSI REG C . imm8b + + IMM shift, and go to state 59 + + imm8b go to state 61 + + +state 48 + + 20 cmp: CMP REG C . REG C REG + + REG shift, and go to state 62 + + +state 49 + + 21 br: BR REG C . USELAB + 22 | BR REG C . imm8bs + + IMM shift, and go to state 63 + USELAB shift, and go to state 64 + + imm8bs go to state 65 + + +state 50 + + 23 sha: SHA REG C . imm6b + 24 | SHA REG C . REG C imm6b + + IMM shift, and go to state 66 + REG shift, and go to state 67 + + imm6b go to state 68 + + +state 51 + + 25 jmpcall: JUMP OSBRA REG . CSBRA + + CSBRA shift, and go to state 69 + + +state 52 + + 26 jmpcall: CALL REG C . OSBRA REG CSBRA + + OSBRA shift, and go to state 70 + + +state 53 + + 27 mov: MOV REG C . REG + + REG shift, and go to state 71 + + +state 54 + + 28 mem: MEM REG C . OBRA REG CBRA + + OBRA shift, and go to state 72 + + +state 55 + + 29 sel: SEL REG C . OBRA REG CBRA + 30 | SEL REG C . REG C OBRA REG CBRA + + OBRA shift, and go to state 73 + REG shift, and go to state 74 + + +state 56 + + 31 seli: SELI REG C . imm2b + 32 | SELI REG C . REG C imm2b + + IMM shift, and go to state 75 + REG shift, and go to state 76 + + imm2b go to state 77 + + +state 57 + + 33 ldl: LDL REG C . imm32 + 34 | LDL REG C . USELAB + + IMM shift, and go to state 78 + USELAB shift, and go to state 79 + + imm32 go to state 80 + + +state 58 + + 17 ari: ARI REG C REG . C REG + + C shift, and go to state 81 + + +state 59 + + 36 imm8b: IMM . + + $default reduce using rule 36 (imm8b) + + +state 60 + + 18 ldsi: LDI REG C imm8b . + + $default reduce using rule 18 (ldsi) + + +state 61 + + 19 ldsi: LSI REG C imm8b . + + $default reduce using rule 19 (ldsi) + + +state 62 + + 20 cmp: CMP REG C REG . C REG + + C shift, and go to state 82 + + +state 63 + + 37 imm8bs: IMM . + + $default reduce using rule 37 (imm8bs) + + +state 64 + + 21 br: BR REG C USELAB . + + $default reduce using rule 21 (br) + + +state 65 + + 22 br: BR REG C imm8bs . + + $default reduce using rule 22 (br) + + +state 66 + + 38 imm6b: IMM . + + $default reduce using rule 38 (imm6b) + + +state 67 + + 24 sha: SHA REG C REG . C imm6b + + C shift, and go to state 83 + + +state 68 + + 23 sha: SHA REG C imm6b . + + $default reduce using rule 23 (sha) + + +state 69 + + 25 jmpcall: JUMP OSBRA REG CSBRA . + + $default reduce using rule 25 (jmpcall) + + +state 70 + + 26 jmpcall: CALL REG C OSBRA . REG CSBRA + + REG shift, and go to state 84 + + +state 71 + + 27 mov: MOV REG C REG . + + $default reduce using rule 27 (mov) + + +state 72 + + 28 mem: MEM REG C OBRA . REG CBRA + + REG shift, and go to state 85 + + +state 73 + + 29 sel: SEL REG C OBRA . REG CBRA + + REG shift, and go to state 86 + + +state 74 + + 30 sel: SEL REG C REG . C OBRA REG CBRA + + C shift, and go to state 87 + + +state 75 + + 35 imm2b: IMM . + + $default reduce using rule 35 (imm2b) + + +state 76 + + 32 seli: SELI REG C REG . C imm2b + + C shift, and go to state 88 + + +state 77 + + 31 seli: SELI REG C imm2b . + + $default reduce using rule 31 (seli) + + +state 78 + + 39 imm32: IMM . + + $default reduce using rule 39 (imm32) + + +state 79 + + 34 ldl: LDL REG C USELAB . + + $default reduce using rule 34 (ldl) + + +state 80 + + 33 ldl: LDL REG C imm32 . + + $default reduce using rule 33 (ldl) + + +state 81 + + 17 ari: ARI REG C REG C . REG + + REG shift, and go to state 89 + + +state 82 + + 20 cmp: CMP REG C REG C . REG + + REG shift, and go to state 90 + + +state 83 + + 24 sha: SHA REG C REG C . imm6b + + IMM shift, and go to state 66 + + imm6b go to state 91 + + +state 84 + + 26 jmpcall: CALL REG C OSBRA REG . CSBRA + + CSBRA shift, and go to state 92 + + +state 85 + + 28 mem: MEM REG C OBRA REG . CBRA + + CBRA shift, and go to state 93 + + +state 86 + + 29 sel: SEL REG C OBRA REG . CBRA + + CBRA shift, and go to state 94 + + +state 87 + + 30 sel: SEL REG C REG C . OBRA REG CBRA + + OBRA shift, and go to state 95 + + +state 88 + + 32 seli: SELI REG C REG C . imm2b + + IMM shift, and go to state 75 + + imm2b go to state 96 + + +state 89 + + 17 ari: ARI REG C REG C REG . + + $default reduce using rule 17 (ari) + + +state 90 + + 20 cmp: CMP REG C REG C REG . + + $default reduce using rule 20 (cmp) + + +state 91 + + 24 sha: SHA REG C REG C imm6b . + + $default reduce using rule 24 (sha) + + +state 92 + + 26 jmpcall: CALL REG C OSBRA REG CSBRA . + + $default reduce using rule 26 (jmpcall) + + +state 93 + + 28 mem: MEM REG C OBRA REG CBRA . + + $default reduce using rule 28 (mem) + + +state 94 + + 29 sel: SEL REG C OBRA REG CBRA . + + $default reduce using rule 29 (sel) + + +state 95 + + 30 sel: SEL REG C REG C OBRA . REG CBRA + + REG shift, and go to state 97 + + +state 96 + + 32 seli: SELI REG C REG C imm2b . + + $default reduce using rule 32 (seli) + + +state 97 + + 30 sel: SEL REG C REG C OBRA REG . CBRA + + CBRA shift, and go to state 98 + + +state 98 + + 30 sel: SEL REG C REG C OBRA REG CBRA . + + $default reduce using rule 30 (sel)
yacc.output Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: lex.in =================================================================== --- lex.in (nonexistent) +++ lex.in (revision 236) @@ -0,0 +1,138 @@ +%option noyywrap + +%{ + +#include +#include +#include "tools.h" + +#include "y.tab.h" + +%} + + +W [ \t\r\n]+ +NL [\n]+ +COMMENT "@"[^\n]*"\n" +IMM ("0x"([0-9a-fA-F]+))|([-]?[0-9]+) +REG "l"[0-7]|"h"[0-7] +OBRA \[ +CBRA \] +OSBRA \< +CSBRA \> +C \, + +LABEL ([_0-9a-zA-Z]+)":" +USELAB ":"([_0-9a-zA-Z]+) + +NOP "nop"|"stop" +LDL "LDL" +ARI "add"|"sub"|"or"|"and"|"xor"|"sh" +LDI "ldi" +LSI "lsi" +SHA "shi"|"shit"|"adi"|"adit" +CMP "cmpl"|"cmpls" +BR "brz"|"brnz" +JUMP "jump" +CALL "call" +MOV "mov" +MEM "ld"|"st"|"ldio"|"stio" +SEL "seh"|"seb" +SELI "seib"|"seih"|"seibs"|"seihs" + +%% +{C} {return C;} +{OBRA} {return OBRA;} +{CBRA} {return CBRA;} +{OSBRA} {return OSBRA;} +{CSBRA} {return CSBRA;} +{LDL} {return LDL;} +{NOP} { if (!strcmp(yytext, "stop")) yylval.num=0xffff; + else yylval.num = 0xe000; + return NOP; + } +{USELAB} {yylval.str=strdup(yytext+1); return USELAB;} +{LABEL} {yylval.str=strdup(yytext); yylval.str[strlen(yytext)-1] = 0; return LABEL;} +{IMM} { + //if(yytext[0]=='\'') { + // yytext[strlen(yytext)-1]=' '; + //} + //yytext[0] = ' '; + yylval.str = (char *) strdup(yytext); + return IMM;} +{REG} { + //yylval.str=strdup(yytext); + yylval.num=atoi(yytext+1); + if(yytext[0]=='h') yylval.num+=8; + return REG;} + +{ARI} { + if(!strcmp(str_toupper(yytext),"ADD")) yylval.num=0x00; + else if(!strcmp(str_toupper(yytext),"SUB")) yylval.num=0x01; + else if(!strcmp(str_toupper(yytext),"AND")) yylval.num=0x02; + else if(!strcmp(str_toupper(yytext),"OR")) yylval.num=0x03; + else if(!strcmp(str_toupper(yytext),"XOR")) yylval.num=0x04; + else if(!strcmp(str_toupper(yytext),"SH")) yylval.num=0x05; + + return ARI; + } +{CMP} { + if(!strcmp(str_toupper(yytext),"CMPL")) yylval.num=0x00; + else if(!strcmp(str_toupper(yytext),"CMPLS")) yylval.num=0x01; + //else if(!strcmp(str_toupper(yytext),"CMPG")) yylval.num=0x02; + //else if(!strcmp(str_toupper(yytext),"CMPGS")) yylval.num=0x03; + return CMP; + } +{JUMP} { yylval.num=0; return JUMP; } +{CALL} { yylval.num=8; return CALL; } +{MOV} { yylval.num=1; return MOV; } +{MEM} { + if(!strcmp(yytext,"ld")) yylval.num=2; + else if(!strcmp(yytext,"st")) yylval.num=3; + else if(!strcmp(yytext,"ldio")) yylval.num=10; + else if(!strcmp(yytext,"stio")) yylval.num=11; + return MEM; + } +{SEL} { + if(!strcmp(yytext,"seh")) yylval.num=4; + else if(!strcmp(yytext,"seb")) yylval.num=5; + return SEL; + } +{SELI} { + if(!strcmp(yytext,"seib")) yylval.num=0x06; + else if(!strcmp(yytext,"seih")) yylval.num=0x16; + else if(!strcmp(yytext,"seibs")) yylval.num=0x26; + else if(!strcmp(yytext,"seihs")) yylval.num=0x36; + return SELI; + } +{LDI} { + return LDI; + } +{LSI} { + return LSI; + } +{BR} { + if(toupper(yytext[2])=='N') yylval.num = 1; + else if(toupper(yytext[2])=='Z') yylval.num = 0; + return BR; + } +{SHA} { + if(toupper(yytext[0])=='A') yylval.num = 0; + else yylval.num = 1; + return SHA; + } +{COMMENT} /* remove comment */ +{W} /* remove ws */ + +%% + +void PROC_FLUSH_BUF ( FILE * xFile ) +{ + yy_delete_buffer ( YY_CURRENT_BUFFER ); + yy_init_globals(); + yy_switch_to_buffer ( yy_create_buffer ( xFile, YY_BUF_SIZE ) ); +} + + +//void main() { while(yylex()); } +
lex.in Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: tools.c =================================================================== --- tools.c (nonexistent) +++ tools.c (revision 236) @@ -0,0 +1,154 @@ + + +#include +#include +#include +#include + + +unsigned int address = 0; +unsigned int hex = 0; +unsigned int addr_table[10000]={0}; + +int hash_init() +{ + return hcreate(100); +} + +void add_label(char *key, unsigned int addr) +{ + ENTRY e, *ep; + + //printf("<%s> added\n", key); + e.key = key; + e.data = (void *) addr; + hsearch(e, ENTER); +} + +unsigned int get_label(char *key) +{ + ENTRY e, *ep; + + e.key = key; + ep = hsearch(e, FIND); + + if(ep) { + //printf("<%s> found\n", key); + return (unsigned int) ep->data; + } else { + //printf("<%s> not found\n", key); + return 0; + } +} + +unsigned int get_abs_label(char *key) +{ + return get_label(key)+0x40; +} + + +char * str_toupper(char *s) +{ + char *str = s; + + while(*s) { + if(isalpha(*s)) *s = toupper(*s); + s++; + } + + return str; +} + +void xprintf(int val) +{ + int i; + if(hex==1) printf("%04x,\n", val); + else if(hex==2) { + for(i=0;i<16;i++){ + printf("%c", '0'+!!(val&0x8000)); + val=val<<1; + } + printf(",\n"); + } + else printf("%c%c", val, (val>>8)); +} + +/* +void hash_add(char *key, char *data) +{ + ENTRY e, *ep; + + e.key = key; + e.data = (void *) data; + hsearch(e, ENTER); +} + + +char * hash_get(char *key) +{ + ENTRY e, *ep; + + e.key = key; + ep = hsearch(e, FIND); + + return (char *) ep->data; +} + +char * macro_insert(char *a) +{ + char *s = malloc(100); + + sprintf(s, "MACRO %s -- MACRO\n", a ); + + return s; +} + +*/ + +int check_imm(char *imm, int *val, int lo, int hi) +{ + int shiftcount = 0; + //char *ret = malloc(100); + int mrx=0; + + if(imm[0]=='0' && imm[1]=='x') { + mrx = sscanf(imm, "%x", val); +// printf("ox: %d", mrx); + } + + if(!mrx) { + mrx = sscanf(imm, "%d", val); +// printf("val: %s -> %d",imm, mrx); + } + + if(mrx){ + if(*val>=lo && *val<=hi) return 0; + else return 1; + } + + + return 2; +} + +/* +char *ari_to_bin(char *s) +{ + char *tmp = malloc(100); + + str_toupper(s); + + if(!strcmp(s, "ADD")) return "0000"; + if(!strcmp(s, "SUB")) return "0001"; + if(!strcmp(s, "ADD")) return "0000"; + if(!strcmp(s, "ADD")) return "0000"; + if(!strcmp(s, "ADD")) return "0000"; + if(!strcmp(s, "ADD")) return "0000"; + if(!strcmp(s, "ADD")) return "0000"; + if(!strcmp(s, "ADD")) return "0000"; + +} */ + + + + +
tools.c Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: yacc.in =================================================================== --- yacc.in (nonexistent) +++ yacc.in (revision 236) @@ -0,0 +1,167 @@ + + +%{ + + +#include +#include +#include "tools.h" + +#define YYERROR_VERBOSE + +int temp; +int firstpass=1; + +void yyerror(const char *str) +{ + fprintf(stderr,"error: %s\n",str); +} + +int yywrap() +{ + return 1; +} + +int main(int argc, char **argv) +{ + if(argc>=2) { + if(!strcmp(argv[1], "-h")) hex = 1; + if(!strcmp(argv[1], "-b")) hex = 2; + } + if(!hash_init()) { + exit(1); + printf("could not create hash table\n"); + } + + if(hex && argc==3) stdin = fopen(argv[2], "r"); + if(!hex && argc==2) stdin = fopen(argv[1], "r"); + + firstpass = 1; + address = 0; + if(yyparse()) exit(1); + firstpass = 0; + address = 0; + rewind(stdin); + (void) PROC_FLUSH_BUF (stdin ); + yyparse(); + return 0; +} + +%} + +%token C OBRA CBRA OSBRA CSBRA NUM + +%union +{ + int num; + char *str; +} + +%token IMM LABEL USELAB +%token REG +%token ARI LDI LSI CMP BR SHA JUMP CALL MOV MEM SEL SELI LDL NOP + +%type asms asm nop ari ldsi cmp br sha jmpcall mov mem sel seli ldl +%type imm6b imm8b imm8bs imm2b imm32 + + + +%% +asms: asm | asms asm + +asm: LABEL {if(firstpass)add_label($1, address);} + | nop {if(!firstpass)xprintf($1);address++;} + | ari {if(!firstpass)xprintf($1);address++;} + | ldsi {if(!firstpass)xprintf($1);address++;} + | cmp {if(!firstpass)xprintf($1);address++;} + | br {if(!firstpass)xprintf($1);address++;} + | sha {if(!firstpass)xprintf($1);address++;} + | jmpcall {if(!firstpass)xprintf($1);address++;} + | mov {if(!firstpass)xprintf($1);address++;} + | mem {if(!firstpass)xprintf($1);address++;} + | sel {if(!firstpass)xprintf($1);address++;} + | seli {if(!firstpass)xprintf($1);address++;} + | ldl {;} + +// | { yyerror("unknown instruction"); YYERROR; } + + +nop: NOP { $$ = $1; } + +ari: ARI REG C REG C REG { $$ = ($1<<12) | ($2<<8) | ($4<<4) | $6; } + +ldsi: LDI REG C imm8b { $$ = (0x6000) | ($2<<8) | ($4&0xff); } + | LSI REG C imm8b { $$ = (0x7000) | ($2<<8) | ($4&0xff); } + +cmp: CMP REG C REG C REG { $$ = (0x8000) | ($1<<12) | ($2<<8) | ($4<<4) | $6;} + +br: BR REG C USELAB { $$ = (0xc000) | ($1<<12) | (((get_label($4)-address)&0xff) << 4) | $2; + // if(!firstpass) printf(" @%d - %d: %d", address, $4, get_label($4)); + } + | BR REG C imm8bs { $$ = (0xc000) | ($1<<12) | (($4&0xff) << 4) | $2; } + +sha: SHA REG C imm6b { $$ = (0xe000) | ($2<<8) | ($1<<6) | ($4&0x3f); } + | SHA REG C REG C imm6b { if(($2^0x8) != $4) { yyerror("wrong sister register"); YYERROR; } + $$ = (0xe000) | ($2<<8) | (1<<7) | ($1<<6) | ($6&0x3f); } + +jmpcall:JUMP OSBRA REG CSBRA { $$ = (0xf000) | ($3<<4) | $1; } + | CALL REG C OSBRA REG CSBRA { $$ = (0xf000) | ($2<<8) | ($5<<4) | $1; } + +mov: MOV REG C REG { $$ = (0xf000) | ($2<<8) | ($4<<4) | 1; } + +mem: MEM REG C OBRA REG CBRA { $$ = (0xf000) | ($2<<8) | ($5<<4) | $1; } + +sel: SEL REG C OBRA REG CBRA { $$ = (0xf000) | ($2<<8) | ($5<<4) | $1; } + | SEL REG C REG C OBRA REG CBRA { if(($2^0x8) != $4) { yyerror("wrong sister register"); YYERROR; } + $$ = (0xf000) | ($2<<8) | ($7<<4) | (1<<3) | $1; } + +seli: SELI REG C imm2b { $$ = (0xf000) | ($2<<8) | ($4<<6) | $1; } + | SELI REG C REG C imm2b { if(($2^0x8) != $4) { yyerror("wrong sister register"); YYERROR; } + $$ = (0xf000) | ($2<<8) | ($6<<4) | (1<<3) | $1; } + +ldl: LDL REG C imm32 + { if(!firstpass)xprintf(0x6000|($2<<8)|(($4>>24)&0xff));address++; + if(!firstpass)xprintf(0x7000|($2<<8)|(($4>>18)&0xff));address++; + if(!firstpass)xprintf(0x7000|($2<<8)|(($4>>8)&0xff));address++; + if(!firstpass)xprintf(0x7000|($2<<8)|(($4>>0)&0xff));address++; + } + | LDL REG C USELAB + { temp = get_abs_label($4); + if(!firstpass)xprintf(0x6000|($2<<8)|((temp>>24)&0xff));address++; + if(!firstpass)xprintf(0x7000|($2<<8)|((temp>>18)&0xff));address++; + if(!firstpass)xprintf(0x7000|($2<<8)|((temp>>8)&0xff));address++; + if(!firstpass)xprintf(0x7000|($2<<8)|((temp>>0)&0xff));address++; + } + + +imm2b: IMM { + temp = check_imm($1, &$$, 0, 3); + if(temp==1) { yyerror("2 Bit immediate expected"); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + } + +imm8b: IMM { + temp = check_imm($1, &$$, 0, 255); + if(temp==1) { yyerror("8 Bit unsigned immediate expected"); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + } +imm8bs: IMM { + temp = check_imm($1, &$$, -128, 127); + if(temp==1) { yyerror("8 bit signed immediate expected"); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + } +// | LABEL { $$ = get_label($1) - address - 1; } + +imm6b: IMM { + temp = check_imm($1, &$$, -32, 31); + if(temp==1) { printf("Immediate Value %d out of range: -32..31 allowed\n", $$); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + } + +imm32: IMM { + temp = check_imm($1, &$$, 0x1000000, 0x7fffffff); + if(temp==1) { printf("Immediate Value %d out of range: -32b..31b allowed\n", $$); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + } + +%%
yacc.in Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: tools.h =================================================================== --- tools.h (nonexistent) +++ tools.h (revision 236) @@ -0,0 +1,20 @@ + +typedef struct myvals { + int num; + int addr; + char *str; +} myval; + + +extern unsigned int address; +extern unsigned int hex; + +void xprintf(int val); +char * str_toupper(char *s); + +int hash_init(); +void add_label(char *key, unsigned int addr); +unsigned int get_label(char *key); +unsigned int get_abs_label(char *key); +void read_labels(FILE *f); +
tools.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: slow_eratost.hex =================================================================== --- slow_eratost.hex (nonexistent) +++ slow_eratost.hex (revision 236) @@ -0,0 +1,62 @@ +671e, +f571, +f55b, +6400, +6000, +6101, +f043, +e401, +dfe5, +e53f, +6402, +f571, +f241, +0224, +8625, +c046, +e000, +dfc6, +f123, +e401, +e000, +a345, +d063, +f342, +dfb3, +e000, +cf23, +e000, +6301, +e301, +8437, +c124, +f532, +dfc5, +e000, +e000, +6c01, +6900, +6d00, +7d00, +7d00, +7d38, +fed8, +7c00, +889c, +dff8, +e901, +cee8, +e000, +d001, +e000, +e000, +e000, +e000, +e000, +e000, +f30b, +e000, +f0e0, +e000, +e000, +e000,
slow_eratost.hex Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: .counter.asm.swp =================================================================== --- .counter.asm.swp (nonexistent) +++ .counter.asm.swp (revision 236) @@ -0,0 +1,2 @@ +b0VIM 7.1áandithoreau~andi/studium/sem9/diogenes_asm/counter.asm +U3210#"! Utpÿad0|üóçØÌÀ½ª›Œ~}| adi l0, 1 adi l4, 1 brnz l1, :1 cmpl l1, l4, l51:lsi l5, 0lsi l5, 0ldi l5, 0x80ldi l4, 0ldi l0nop \ No newline at end of file
.counter.asm.swp Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: Makefile =================================================================== --- Makefile (nonexistent) +++ Makefile (revision 236) @@ -0,0 +1,29 @@ + + +all: + bison -d --verbose yacc.in + cp yacc.tab.in y.tab.c + cp yacc.tab.in.h y.tab.h + flex lex.in + gcc y.tab.c lex.yy.c tools.c -o asm + ./asm -h eratost.asm + +bin: + @./asm -b eratost.asm + @echo ; + +all2: + yacc -d templates.yacc + lex templates.lex + tcc -Itcc-0.9.23\include -Ltcc-0.9.23\lib y.tab.c lex.yy.c tools.c + +clean: + rm *.o + +run2: all2 + ./a.out + +run: all + ./a.out + +
Makefile Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: yacc.in.tab.h =================================================================== --- yacc.in.tab.h (nonexistent) +++ yacc.in.tab.h (revision 236) @@ -0,0 +1,27 @@ +typedef union +{ + int num; + char *str; +} YYSTYPE; +#define C 257 +#define OBRA 258 +#define CBRA 259 +#define NUM 260 +#define IMM 261 +#define IMMHEX 262 +#define REG 263 +#define SKIP 264 +#define SKIPAL 265 +#define COND 266 +#define MOV 267 +#define ARI 268 +#define CMP 269 +#define CMPTYP 270 +#define SC 271 +#define BL 272 +#define MEM 273 +#define IO 274 +#define LABEL 275 + + +extern YYSTYPE yylval;
yacc.in.tab.h Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: yacc.in.tab.c =================================================================== --- yacc.in.tab.c (nonexistent) +++ yacc.in.tab.c (revision 236) @@ -0,0 +1,1056 @@ + +/* A Bison parser, made from yacc.in + by GNU Bison version 1.27 + */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define C 257 +#define OBRA 258 +#define CBRA 259 +#define NUM 260 +#define IMM 261 +#define IMMHEX 262 +#define REG 263 +#define SKIP 264 +#define SKIPAL 265 +#define COND 266 +#define MOV 267 +#define ARI 268 +#define CMP 269 +#define CMPTYP 270 +#define SC 271 +#define BL 272 +#define MEM 273 +#define IO 274 +#define LABEL 275 + +#line 3 "yacc.in" + +#include +#include +#include "tools.h" + +#define YYERROR_VERBOSE + +int temp; + +void yyerror(const char *str) +{ + fprintf(stderr,"error: %s\n",str); +} + +int yywrap() +{ + return 1; +} + +int main(int argc, char **argv) +{ +// if(argc==2) +// stdin = fopen(argv[1], "r"); + + yyparse(); +} + + +#line 34 "yacc.in" +typedef union +{ + int num; + char *str; +} YYSTYPE; +#include + +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif + + + +#define YYFINAL 43 +#define YYFLAG -32768 +#define YYNTBASE 22 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 275 ? yytranslate[x] : 32) + +static const char yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21 +}; + +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 2, 5, 7, 9, 11, 13, 15, 17, 22, + 27, 34, 39, 44, 51, 54, 59, 61, 63, 65 +}; + +static const short yyrhs[] = { 23, + 0, 22, 23, 0, 21, 0, 24, 0, 25, 0, + 28, 0, 26, 0, 27, 0, 13, 9, 3, 9, + 0, 13, 9, 3, 29, 0, 14, 9, 3, 9, + 3, 9, 0, 14, 9, 3, 31, 0, 15, 9, + 3, 9, 0, 19, 9, 3, 4, 9, 5, 0, + 11, 30, 0, 10, 9, 3, 30, 0, 7, 0, + 7, 0, 21, 0, 7, 0 +}; + +#endif + +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 50, 50, 52, 53, 54, 55, 56, 57, 60, 64, + 69, 73, 78, 80, 85, 86, 88, 94, 99, 104 +}; +#endif + + +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) + +static const char * const yytname[] = { "$","error","$undefined.","C","OBRA", +"CBRA","NUM","IMM","IMMHEX","REG","SKIP","SKIPAL","COND","MOV","ARI","CMP","CMPTYP", +"SC","BL","MEM","IO","LABEL","asms","asm","mov","arit","cmp","mem","skip","imm", +"immsk","imm5b", NULL +}; +#endif + +static const short yyr1[] = { 0, + 22, 22, 23, 23, 23, 23, 23, 23, 24, 24, + 25, 25, 26, 27, 28, 28, 29, 30, 30, 31 +}; + +static const short yyr2[] = { 0, + 1, 2, 1, 1, 1, 1, 1, 1, 4, 4, + 6, 4, 4, 6, 2, 4, 1, 1, 1, 1 +}; + +static const short yydefact[] = { 0, + 0, 0, 0, 0, 0, 0, 3, 0, 1, 4, + 5, 7, 8, 6, 0, 18, 19, 15, 0, 0, + 0, 0, 2, 0, 0, 0, 0, 0, 16, 17, + 9, 10, 20, 0, 12, 13, 0, 0, 0, 11, + 14, 0, 0 +}; + +static const short yydefgoto[] = { 8, + 9, 10, 11, 12, 13, 14, 32, 18, 35 +}; + +static const short yypact[] = { 12, + -4, -5, -2, -1, 3, 8,-32768, 0,-32768,-32768, +-32768,-32768,-32768,-32768, 6,-32768,-32768,-32768, 15, 17, + 21, 25,-32768, -5, -6, -3, 20, 26,-32768,-32768, +-32768,-32768,-32768, 29,-32768,-32768, 27, 28, 30,-32768, +-32768, 34,-32768 +}; + +static const short yypgoto[] = {-32768, + 31,-32768,-32768,-32768,-32768,-32768,-32768, 14,-32768 +}; + + +#define YYLAST 39 + + +static const short yytable[] = { 42, + 30, 16, 31, 33, 15, 34, 19, 20, 24, 1, + 2, 21, 3, 4, 5, 17, 22, 25, 6, 26, + 7, 1, 2, 27, 3, 4, 5, 28, 36, 37, + 6, 38, 7, 43, 41, 39, 40, 29, 23 +}; + +static const short yycheck[] = { 0, + 7, 7, 9, 7, 9, 9, 9, 9, 3, 10, + 11, 9, 13, 14, 15, 21, 9, 3, 19, 3, + 21, 10, 11, 3, 13, 14, 15, 3, 9, 4, + 19, 3, 21, 0, 5, 9, 9, 24, 8 +}; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "bison.simple" +/* This file comes from bison-1.27. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(token, value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +#ifndef YYPURE +#define YYLEX yylex() +#endif + +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ +#endif + +/* If nonreentrant, generate the variables here */ + +#ifndef YYPURE + +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ + +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ +#endif + +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ + +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ +#endif + +/* YYINITDEPTH indicates the initial size of the parser's stacks */ + +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ + +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 10000 +#endif + +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#else /* __cplusplus */ + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (char *to, char *from, unsigned int count) +{ + register char *t = to; + register char *f = from; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#endif +#endif + +#line 216 "bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +#define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; + +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ + + int yylen; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss - 1; + yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif + +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif + + /* Get the current used size of the three stacks, in elements. */ + int size = yyssp - yyss + 1; + +#ifdef yyoverflow + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif + + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif +#else /* no yyoverflow */ + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif +#endif /* no yyoverflow */ + + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif + + goto yybackup; + yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif + } + else + { + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; + + yystate = yyn; + goto yynewstate; + +/* Do the default action for the current state. */ +yydefault: + + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + +/* Do a reduction. yyn is the number of a rule to reduce with. */ +yyreduce: + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ + +#if YYDEBUG != 0 + if (yydebug) + { + int i; + + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + + switch (yyn) { + +case 3: +#line 52 "yacc.in" +{add_label(yyval.num, address);; + break;} +case 4: +#line 53 "yacc.in" +{printf("0x%04x\n",yyvsp[0].num);address++;; + break;} +case 5: +#line 54 "yacc.in" +{printf("0x%04x\n",yyvsp[0].num);address++;; + break;} +case 6: +#line 55 "yacc.in" +{printf("0x%04x\n",yyvsp[0].num);address++;; + break;} +case 7: +#line 56 "yacc.in" +{printf("0x%04x\n",yyvsp[0].num);address++;; + break;} +case 8: +#line 57 "yacc.in" +{printf("0x%04x\n",yyvsp[0].num);address++;; + break;} +case 9: +#line 61 "yacc.in" +{ if(yyvsp[-2].num==0) { yyerror("r0 not allowed as destination"); YYERROR; } + yyval.num = (yyvsp[-2].num<<8) | (yyvsp[0].num<<4); // add regD, regS, reg0 + ; + break;} +case 10: +#line 65 "yacc.in" +{ if(yyvsp[-2].num==0) { yyerror("r0 not allowed as destination"); YYERROR; } + yyval.num = (0x7<<12) | (yyvsp[-2].num<<8) | (yyvsp[0].num); // ldi regD, regS, reg0 + ; + break;} +case 11: +#line 70 "yacc.in" +{ if(yyvsp[-4].num==0) { yyerror("r0 not allowed as destination"); YYERROR; } + yyval.num = (yyvsp[-5].num<<12) | (yyvsp[-4].num<<8) | (yyvsp[-2].num<<4) | yyvsp[0].num; + ; + break;} +case 12: +#line 74 "yacc.in" +{ if(!(yyvsp[-2].num%2)) { yyerror("only odd registers allowed"); YYERROR; } + yyval.num = (yyvsp[-3].num<<12) | ((yyvsp[-2].num-1)<<4) | (yyvsp[0].num); + ; + break;} +case 13: +#line 78 "yacc.in" +{ yyval.num = 0xE000 | (yyvsp[-3].num<<9) | (yyvsp[-2].num<<4) | yyvsp[0].num; ; + break;} +case 14: +#line 81 "yacc.in" +{ if(yyvsp[-4].num==0) { yyerror("r0 not allowed as destination"); YYERROR; } + yyval.num = 0x8000 | (yyvsp[-5].num<<12) | (yyvsp[-4].num<<4) | yyvsp[-1].num + ; + break;} +case 15: +#line 85 "yacc.in" +{ yyval.num = (0xc<<12) | ((yyvsp[0].num&0xff)<<4); ; + break;} +case 16: +#line 86 "yacc.in" +{ yyval.num = (0xc<<12) | (yyvsp[-3].num<<12) | ((yyvsp[0].num&0xff)<<4) | yyvsp[-2].num; ; + break;} +case 17: +#line 89 "yacc.in" +{ temp = check_imm(yyvsp[0].str, &yyval.num, 0, 255); + if(temp==1) { yyerror("8 Bit unsigned immediate expected"); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ; + break;} +case 18: +#line 95 "yacc.in" +{ temp = check_imm(yyvsp[0].str, &yyval.num, -128, 127); + if(temp==1) { yyerror("8 bit signed immediate expected"); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ; + break;} +case 19: +#line 100 "yacc.in" +{ + yyval.num = get_label(yyvsp[0].num) - address - 1; + ; + break;} +case 20: +#line 105 "yacc.in" +{ temp = check_imm(yyvsp[0].str, &yyval.num, 1, 32); + yyval.num--; + if(temp==1) { printf("Immediate Value %d out of range: 1..32 allowed\n", yyval.num); YYERROR; } + if(temp==2) { yyerror("Immediate syntax"); YYERROR; } + ; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 542 "bison.simple" + + yyvsp -= yylen; + yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; + +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif + + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + +yyerrlab: /* here on detecting error */ + + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); + + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror("parse error"); + } + + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ + + if (yyerrstatus == 3) + { + /* if just tried and failed to reuse lookahead token after an error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token + after shifting the error token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif + +yyerrpop: /* pop the current state because it cannot handle the error token */ + + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; +} +#line 112 "yacc.in" +
yacc.in.tab.c Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: asm.pnps =================================================================== --- asm.pnps (nonexistent) +++ asm.pnps (revision 236) @@ -0,0 +1 @@ + \ No newline at end of file
asm.pnps Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: asm.pnproj =================================================================== --- asm.pnproj (nonexistent) +++ asm.pnproj (revision 236) @@ -0,0 +1 @@ + \ No newline at end of file
asm.pnproj Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: macros.c =================================================================== --- macros.c (nonexistent) +++ macros.c (revision 236) @@ -0,0 +1,140 @@ + + +#include +#include + +#define RDLINE() fgets(line, 1024, stdin) + +#define STATE_MACRO 1 +#define STATE_ENDM 2 +#define STATE_USEM 3 + + +char line[1024]; +char *p; + +char buffer[10000]; + + +void get_params(char *p, char names[12][256]) { + int newname = 0; + int i=0, j=0; + + if(!p) return; + + memset(names, 0, 12*256); + + while(*p) { + + if(isalnum(*p)) { + newname = 1; + names[i][j++] = *p; + } else { + if(newname==1) { + names[i][j] = 0; + j=0; + i++; + } + newname = 0; + } + + p++; + } +} + + +char *dollarfy(char *srci, char names[12][256]) +{ + int i=2; + char *dest, *src, *h; + char *pd, *ps; + + src = malloc(strlen(srci) + 12); + dest = malloc(strlen(srci) + 12); + strcpy(src, srci); + + while(names[i][0]) { + pd = dest; + ps = src; + + while(*ps) { + if(*ps=='\\') + if(!strncmp(++ps, names[i], strlen(names[i]))) { + while(*ps && isalnum(*ps++)); + ps--; + *pd++ = '$'; + *pd++ = ('0' + i-2); + *pd = ' '; + } else ps--; + *pd = *ps; + pd++; + ps++; + } + *pd = 0; + i++; + h = src; + src = dest; + dest = h; + } + + free(dest); + return src; +} + + +int hash_macros() +{ + int state=0; + char *p; + buffer[0] = 0; + ENTRY e, *ep; + char name[128]; + char parm[12][256]; + + if(!RDLINE()) return 1; + + + while(1) { + if(p = strstr(line, ".macro")) { + sscanf(line, " .macro %s ", name); + get_params(p, parm); + if(!RDLINE()) return 1; + state = STATE_MACRO; + } + else if(p = strstr(line, ".endm")) state = STATE_ENDM; + else if(p = strstr(line, ".usem")) { + state = STATE_USEM; + sscanf(line, " .usem %s ", name); + } + + switch(state) { + case STATE_MACRO: strcat(buffer, line); break; + case STATE_ENDM: + p = dollarfy(buffer, parm); + e.key = strdup(name); + e.data = (void *) p; + hsearch(e, ENTER); + state = 0; buffer[0] = 0; + break; + case STATE_USEM: + e.key = strdup(name); + ep = hsearch(e, FIND); + if(ep) printf((char *) ep->data); + state = 0; buffer[0] = 0; + break; + default: printf(line); + } + if(!RDLINE()) return 1; + } +} + + +int main(int argc, char **argv) +{ + + hcreate(100); + + hash_macros(); + + +}
macros.c Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property

powered by: WebSVN 2.1.0

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