#define panic(m) {fprintf(stderr,"Panic: %s!\n",m) ;exit(-2) ;} #define sign_bit ((unsigned) 0x80000000) \ #define mm 0x98 #define lop_quote 0x0 #define lop_loc 0x1 #define lop_skip 0x2 #define lop_fixo 0x3 #define lop_fixr 0x4 #define lop_fixrx 0x5 #define lop_file 0x6 #define lop_line 0x7 #define lop_spec 0x8 #define lop_pre 0x9 #define lop_post 0xa #define lop_stab 0xb #define lop_end 0xc \ #define mmo_err { \ fprintf(stderr,"Bad object file! (Try running MMOtype.)\n") ; \ \ exit(-4) ; \ } \ #define mmo_load(loc,val) ll= mem_find(loc) ,ll->tet^= val \ #define ybyte buf[2] #define zbyte buf[3] \ #define X_BIT (1<<8) #define Z_BIT (1<<9) #define U_BIT (1<<10) #define O_BIT (1<<11) #define I_BIT (1<<12) #define W_BIT (1<<13) #define V_BIT (1<<14) #define D_BIT (1<<15) #define H_BIT (1<<16) \ #define trace_bit (1<<3) #define read_bit (1<<2) #define write_bit (1<<1) #define exec_bit (1<<0) \ #define max_sys_call Ftell \ #define Z_is_immed_bit 0x1 #define Z_is_source_bit 0x2 #define Y_is_immed_bit 0x4 #define Y_is_source_bit 0x8 #define X_is_source_bit 0x10 #define X_is_dest_bit 0x20 #define rel_addr_bit 0x40 #define push_pop_bit 0x80 \ #define VERSION 1 #define SUBVERSION 0 #define SUBSUBVERSION 1 \ #define test_store_bkpt(ll) if((ll) ->bkpt&write_bit) breakpoint= tracing= true \ #define test_load_bkpt(ll) if((ll) ->bkpt&read_bit) breakpoint= tracing= true \ #define shift_amt (z.h||z.l>=64?64:z.l) \ #define cmp_zero store_x \ #define ROUND_OFF 1 #define ROUND_UP 2 #define ROUND_DOWN 3 #define ROUND_NEAR 4 \ #define RESUME_AGAIN 0 #define RESUME_CONT 1 #define RESUME_SET 2 \ #define rhs &switchable_string[1] \ #define mmo_file_name *cur_arg \ #define command_buf_size 1024 \ /*141:*/ #line 2863 "mmix-sim.w" #include #include #include #include #include #include "abstime.h" /*11:*/ #line 569 "mmix-sim.w" #ifdef __STDC__ #define ARGS(list) list #else #define ARGS(list) () #endif /*:11*//*43:*/ #line 1121 "mmix-sim.w" #include #include /*:43*//*46:*/ #line 1157 "mmix-sim.w" #ifndef SEEK_SET #define SEEK_SET 0 #endif /*:46*/ #line 2870 "mmix-sim.w" /*9:*/ #line 547 "mmix-sim.w" typedef enum{false,true}bool; /*:9*//*10:*/ #line 559 "mmix-sim.w" typedef unsigned int tetra; typedef struct{tetra h,l;}octa; typedef unsigned char byte; /*:10*//*16:*/ #line 720 "mmix-sim.w" typedef struct{ tetra tet; tetra freq; unsigned char bkpt; unsigned char file_no; unsigned short line_no; }mem_tetra; typedef struct mem_node_struct{ octa loc; tetra stamp; struct mem_node_struct*left,*right; mem_tetra dat[512]; }mem_node; /*:16*//*38:*/ #line 1064 "mmix-sim.w" typedef struct{ char*name; int line_count; long*map; }file_node; /*:38*//*39:*/ #line 1074 "mmix-sim.w" typedef char Char; /*:39*//*54:*/ #line 1268 "mmix-sim.w" typedef enum{ TRAP,FCMP,FUN,FEQL,FADD,FIX,FSUB,FIXU, FLOT,FLOTI,FLOTU,FLOTUI,SFLOT,SFLOTI,SFLOTU,SFLOTUI, FMUL,FCMPE,FUNE,FEQLE,FDIV,FSQRT,FREM,FINT, MUL,MULI,MULU,MULUI,DIV,DIVI,DIVU,DIVUI, ADD,ADDI,ADDU,ADDUI,SUB,SUBI,SUBU,SUBUI, IIADDU,IIADDUI,IVADDU,IVADDUI,VIIIADDU,VIIIADDUI,XVIADDU,XVIADDUI, CMP,CMPI,CMPU,CMPUI,NEG,NEGI,NEGU,NEGUI, SL,SLI,SLU,SLUI,SR,SRI,SRU,SRUI, BN,BNB,BZ,BZB,BP,BPB,BOD,BODB, BNN,BNNB,BNZ,BNZB,BNP,BNPB,BEV,BEVB, PBN,PBNB,PBZ,PBZB,PBP,PBPB,PBOD,PBODB, PBNN,PBNNB,PBNZ,PBNZB,PBNP,PBNPB,PBEV,PBEVB, CSN,CSNI,CSZ,CSZI,CSP,CSPI,CSOD,CSODI, CSNN,CSNNI,CSNZ,CSNZI,CSNP,CSNPI,CSEV,CSEVI, ZSN,ZSNI,ZSZ,ZSZI,ZSP,ZSPI,ZSOD,ZSODI, ZSNN,ZSNNI,ZSNZ,ZSNZI,ZSNP,ZSNPI,ZSEV,ZSEVI, LDB,LDBI,LDBU,LDBUI,LDW,LDWI,LDWU,LDWUI, LDT,LDTI,LDTU,LDTUI,LDO,LDOI,LDOU,LDOUI, LDSF,LDSFI,LDHT,LDHTI,CSWAP,CSWAPI,LDUNC,LDUNCI, LDVTS,LDVTSI,PRELD,PRELDI,PREGO,PREGOI,GO,GOI, STB,STBI,STBU,STBUI,STW,STWI,STWU,STWUI, STT,STTI,STTU,STTUI,STO,STOI,STOU,STOUI, STSF,STSFI,STHT,STHTI,STCO,STCOI,STUNC,STUNCI, SYNCD,SYNCDI,PREST,PRESTI,SYNCID,SYNCIDI,PUSHGO,PUSHGOI, OR,ORI,ORN,ORNI,NOR,NORI,XOR,XORI, AND,ANDI,ANDN,ANDNI,NAND,NANDI,NXOR,NXORI, BDIF,BDIFI,WDIF,WDIFI,TDIF,TDIFI,ODIF,ODIFI, MUX,MUXI,SADD,SADDI,MOR,MORI,MXOR,MXORI, SETH,SETMH,SETML,SETL,INCH,INCMH,INCML,INCL, ORH,ORMH,ORML,ORL,ANDNH,ANDNMH,ANDNML,ANDNL, JMP,JMPB,PUSHJ,PUSHJB,GETA,GETAB,PUT,PUTI, POP,RESUME,SAVE,UNSAVE,SYNC,SWYM,GET,TRIP}mmix_opcode; /*:54*//*55:*/ #line 1305 "mmix-sim.w" typedef enum{ rB,rD,rE,rH,rJ,rM,rR,rBB, rC,rN,rO,rS,rI,rT,rTT,rK,rQ,rU,rV,rG,rL, rA,rF,rP,rW,rX,rY,rZ,rWW,rXX,rYY,rZZ}special_reg; /*:55*//*59:*/ #line 1344 "mmix-sim.w" typedef enum{ Halt,Fopen,Fclose,Fread,Fgets,Fgetws, Fwrite,Fputs,Fputws,Fseek,Ftell}sys_call; /*:59*//*64:*/ #line 1423 "mmix-sim.w" typedef struct{ char*name; unsigned char flags; unsigned char third_operand; unsigned char mems; unsigned char oops; char*trace_format; }op_info; /*:64*//*135:*/ #line 2788 "mmix-sim.w" typedef enum{decimal,hex,zhex,floating,handle}fmt_style; /*:135*/ #line 2871 "mmix-sim.w" /*19:*/ #line 763 "mmix-sim.w" tetra priority= 314159265; mem_node*mem_root; mem_node*last_mem; /*:19*//*25:*/ #line 865 "mmix-sim.w" FILE*mmo_file; int postamble; int byte_count; byte buf[4]; int yzbytes; int delta; tetra tet; /*:25*//*31:*/ #line 949 "mmix-sim.w" octa cur_loc; int cur_file= -1; int cur_line; octa tmp; tetra obj_time; /*:31*//*40:*/ #line 1077 "mmix-sim.w" file_node file_info[256]; int buf_size; Char*buffer; /*:40*//*48:*/ #line 1185 "mmix-sim.w" FILE*src_file; int shown_file= -1; int shown_line; int gap; bool line_shown; bool showing_source; int profile_gap; bool profile_showing_source; /*:48*//*52:*/ #line 1251 "mmix-sim.w" octa implied_loc; bool profile_started; /*:52*//*56:*/ #line 1311 "mmix-sim.w" char*special_name[32]= {"rB","rD","rE","rH","rJ","rM","rR","rBB", "rC","rN","rO","rS","rI","rT","rTT","rK","rQ","rU","rV","rG","rL", "rA","rF","rP","rW","rX","rY","rZ","rWW","rXX","rYY","rZZ"}; /*:56*//*61:*/ #line 1377 "mmix-sim.w" octa w,x,y,z,a,b,ma,mb; octa*x_ptr; octa loc; octa inst_ptr; tetra inst; int old_L; int exc; int tracing_exceptions; int rop; int round_mode; bool resuming; bool halted; bool breakpoint; bool tracing; bool stack_tracing; bool interacting; bool interact_after_break; bool tripping; bool good; tetra trace_threshold; /*:61*//*65:*/ #line 1454 "mmix-sim.w" op_info info[256]= { /*66:*/ #line 1461 "mmix-sim.w" {"TRAP",0x0a,255,0,5,"%r"}, {"FCMP",0x2a,0,0,1,"%l = %.y cmp %.z = %x"}, {"FUN",0x2a,0,0,1,"%l = [%.y(||)%.z] = %x"}, {"FEQL",0x2a,0,0,1,"%l = [%.y(==)%.z] = %x"}, {"FADD",0x2a,0,0,4,"%l = %.y %(+%) %.z = %.x"}, {"FIX",0x26,0,0,4,"%l = %(fix%) %.z = %x"}, {"FSUB",0x2a,0,0,4,"%l = %.y %(-%) %.z = %.x"}, {"FIXU",0x26,0,0,4,"%l = %(fix%) %.z = %#x"}, {"FLOT",0x26,0,0,4,"%l = %(flot%) %z = %.x"}, {"FLOTI",0x25,0,0,4,"%l = %(flot%) %z = %.x"}, {"FLOTU",0x26,0,0,4,"%l = %(flot%) %#z = %.x"}, {"FLOTUI",0x25,0,0,4,"%l = %(flot%) %z = %.x"}, {"SFLOT",0x26,0,0,4,"%l = %(sflot%) %z = %.x"}, {"SFLOTI",0x25,0,0,4,"%l = %(sflot%) %z = %.x"}, {"SFLOTU",0x26,0,0,4,"%l = %(sflot%) %#z = %.x"}, {"SFLOTUI",0x25,0,0,4,"%l = %(sflot%) %z = %.x"}, {"FMUL",0x2a,0,0,4,"%l = %.y %(*%) %.z = %.x"}, {"FCMPE",0x2a,rE,0,4,"%l = %.y cmp %.z (%.b)) = %x"}, {"FUNE",0x2a,rE,0,1,"%l = [%.y(||)%.z (%.b)] = %x"}, {"FEQLE",0x2a,rE,0,4,"%l = [%.y(==)%.z (%.b)] = %x"}, {"FDIV",0x2a,0,0,40,"%l = %.y %(/%) %.z = %.x"}, {"FSQRT",0x26,0,0,40,"%l = %(sqrt%) %.z = %.x"}, {"FREM",0x2a,0,0,4,"%l = %.y %(rem%) %.z = %.x"}, {"FINT",0x26,0,0,4,"%l = %(int%) %.z = %.x"}, {"MUL",0x2a,0,0,10,"%l = %y * %z = %x"}, {"MULI",0x29,0,0,10,"%l = %y * %z = %x"}, {"MULU",0x2a,0,0,10,"%l = %#y * %#z = %#x, rH=%#a"}, {"MULUI",0x29,0,0,10,"%l = %#y * %z = %#x, rH=%#a"}, {"DIV",0x2a,0,0,60,"%l = %y / %z = %x, rR=%a"}, {"DIVI",0x29,0,0,60,"%l = %y / %z = %x, rR=%a"}, {"DIVU",0x2a,rD,0,60,"%l = %#b%0y / %#z = %#x, rR=%#a"}, {"DIVUI",0x29,rD,0,60,"%l = %#b%0y / %z = %#x, rR=%#a"}, {"ADD",0x2a,0,0,1,"%l = %y + %z = %x"}, {"ADDI",0x29,0,0,1,"%l = %y + %z = %x"}, {"ADDU",0x2a,0,0,1,"%l = %#y + %#z = %#x"}, {"ADDUI",0x29,0,0,1,"%l = %#y + %z = %#x"}, {"SUB",0x2a,0,0,1,"%l = %y - %z = %x"}, {"SUBI",0x29,0,0,1,"%l = %y - %z = %x"}, {"SUBU",0x2a,0,0,1,"%l = %#y - %#z = %#x"}, {"SUBUI",0x29,0,0,1,"%l = %#y - %z = %#x"}, {"2ADDU",0x2a,0,0,1,"%l = %#y <<1+ %#z = %#x"}, {"2ADDUI",0x29,0,0,1,"%l = %#y <<1+ %z = %#x"}, {"4ADDU",0x2a,0,0,1,"%l = %#y <<2+ %#z = %#x"}, {"4ADDUI",0x29,0,0,1,"%l = %#y <<2+ %z = %#x"}, {"8ADDU",0x2a,0,0,1,"%l = %#y <<3+ %#z = %#x"}, {"8ADDUI",0x29,0,0,1,"%l = %#y <<3+ %z = %#x"}, {"16ADDU",0x2a,0,0,1,"%l = %#y <<4+ %#z = %#x"}, {"16ADDUI",0x29,0,0,1,"%l = %#y <<4+ %z = %#x"}, {"CMP",0x2a,0,0,1,"%l = %y cmp %z = %x"}, {"CMPI",0x29,0,0,1,"%l = %y cmp %z = %x"}, {"CMPU",0x2a,0,0,1,"%l = %#y cmp %#z = %x"}, {"CMPUI",0x29,0,0,1,"%l = %#y cmp %z = %x"}, {"NEG",0x26,0,0,1,"%l = %y - %z = %x"}, {"NEGI",0x25,0,0,1,"%l = %y - %z = %x"}, {"NEGU",0x26,0,0,1,"%l = %y - %#z = %#x"}, {"NEGUI",0x25,0,0,1,"%l = %y - %z = %#x"}, {"SL",0x2a,0,0,1,"%l = %y << %#z = %x"}, {"SLI",0x29,0,0,1,"%l = %y << %z = %x"}, {"SLU",0x2a,0,0,1,"%l = %#y << %#z = %#x"}, {"SLUI",0x29,0,0,1,"%l = %#y << %z = %#x"}, {"SR",0x2a,0,0,1,"%l = %y >> %#z = %x"}, {"SRI",0x29,0,0,1,"%l = %y >> %z = %x"}, {"SRU",0x2a,0,0,1,"%l = %#y >> %#z = %#x"}, {"SRUI",0x29,0,0,1,"%l = %#y >> %z = %#x"} /*:66*/ #line 1456 "mmix-sim.w" , /*67:*/ #line 1527 "mmix-sim.w" {"BN",0x50,0,0,1,"%b<0? %t%g"}, {"BNB",0x50,0,0,1,"%b<0? %t%g"}, {"BZ",0x50,0,0,1,"%b==0? %t%g"}, {"BZB",0x50,0,0,1,"%b==0? %t%g"}, {"BP",0x50,0,0,1,"%b>0? %t%g"}, {"BPB",0x50,0,0,1,"%b>0? %t%g"}, {"BOD",0x50,0,0,1,"%b odd? %t%g"}, {"BODB",0x50,0,0,1,"%b odd? %t%g"}, {"BNN",0x50,0,0,1,"%b>=0? %t%g"}, {"BNNB",0x50,0,0,1,"%b>=0? %t%g"}, {"BNZ",0x50,0,0,1,"%b!=0? %t%g"}, {"BNZB",0x50,0,0,1,"%b!=0? %t%g"}, {"BNP",0x50,0,0,1,"%b<=0? %t%g"}, {"BNPB",0x50,0,0,1,"%b<=0? %t%g"}, {"BEV",0x50,0,0,1,"%b even? %t%g"}, {"BEVB",0x50,0,0,1,"%b even? %t%g"}, {"PBN",0x50,0,0,1,"%b<0? %t%g"}, {"PBNB",0x50,0,0,1,"%b<0? %t%g"}, {"PBZ",0x50,0,0,1,"%b==0? %t%g"}, {"PBZB",0x50,0,0,1,"%b==0? %t%g"}, {"PBP",0x50,0,0,1,"%b>0? %t%g"}, {"PBPB",0x50,0,0,1,"%b>0? %t%g"}, {"PBOD",0x50,0,0,1,"%b odd? %t%g"}, {"PBODB",0x50,0,0,1,"%b odd? %t%g"}, {"PBNN",0x50,0,0,1,"%b>=0? %t%g"}, {"PBNNB",0x50,0,0,1,"%b>=0? %t%g"}, {"PBNZ",0x50,0,0,1,"%b!=0? %t%g"}, {"PBNZB",0x50,0,0,1,"%b!=0? %t%g"}, {"PBNP",0x50,0,0,1,"%b<=0? %t%g"}, {"PBNPB",0x50,0,0,1,"%b<=0? %t%g"}, {"PBEV",0x50,0,0,1,"%b even? %t%g"}, {"PBEVB",0x50,0,0,1,"%b even? %t%g"}, {"CSN",0x3a,0,0,1,"%l = %y<0? %z: %b = %x"}, {"CSNI",0x39,0,0,1,"%l = %y<0? %z: %b = %x"}, {"CSZ",0x3a,0,0,1,"%l = %y==0? %z: %b = %x"}, {"CSZI",0x39,0,0,1,"%l = %y==0? %z: %b = %x"}, {"CSP",0x3a,0,0,1,"%l = %y>0? %z: %b = %x"}, {"CSPI",0x39,0,0,1,"%l = %y>0? %z: %b = %x"}, {"CSOD",0x3a,0,0,1,"%l = %y odd? %z: %b = %x"}, {"CSODI",0x39,0,0,1,"%l = %y odd? %z: %b = %x"}, {"CSNN",0x3a,0,0,1,"%l = %y>=0? %z: %b = %x"}, {"CSNNI",0x39,0,0,1,"%l = %y>=0? %z: %b = %x"}, {"CSNZ",0x3a,0,0,1,"%l = %y!=0? %z: %b = %x"}, {"CSNZI",0x39,0,0,1,"%l = %y!=0? %z: %b = %x"}, {"CSNP",0x3a,0,0,1,"%l = %y<=0? %z: %b = %x"}, {"CSNPI",0x39,0,0,1,"%l = %y<=0? %z: %b = %x"}, {"CSEV",0x3a,0,0,1,"%l = %y even? %z: %b = %x"}, {"CSEVI",0x39,0,0,1,"%l = %y even? %z: %b = %x"}, {"ZSN",0x2a,0,0,1,"%l = %y<0? %z: 0 = %x"}, {"ZSNI",0x29,0,0,1,"%l = %y<0? %z: 0 = %x"}, {"ZSZ",0x2a,0,0,1,"%l = %y==0? %z: 0 = %x"}, {"ZSZI",0x29,0,0,1,"%l = %y==0? %z: 0 = %x"}, {"ZSP",0x2a,0,0,1,"%l = %y>0? %z: 0 = %x"}, {"ZSPI",0x29,0,0,1,"%l = %y>0? %z: 0 = %x"}, {"ZSOD",0x2a,0,0,1,"%l = %y odd? %z: 0 = %x"}, {"ZSODI",0x29,0,0,1,"%l = %y odd? %z: 0 = %x"}, {"ZSNN",0x2a,0,0,1,"%l = %y>=0? %z: 0 = %x"}, {"ZSNNI",0x29,0,0,1,"%l = %y>=0? %z: 0 = %x"}, {"ZSNZ",0x2a,0,0,1,"%l = %y!=0? %z: 0 = %x"}, {"ZSNZI",0x29,0,0,1,"%l = %y!=0? %z: 0 = %x"}, {"ZSNP",0x2a,0,0,1,"%l = %y<=0? %z: 0 = %x"}, {"ZSNPI",0x29,0,0,1,"%l = %y<=0? %z: 0 = %x"}, {"ZSEV",0x2a,0,0,1,"%l = %y even? %z: 0 = %x"}, {"ZSEVI",0x29,0,0,1,"%l = %y even? %z: 0 = %x"} /*:67*/ #line 1457 "mmix-sim.w" , /*68:*/ #line 1593 "mmix-sim.w" {"LDB",0x2a,0,1,1,"%l = M1[%#y+%#z] = %x"}, {"LDBI",0x29,0,1,1,"%l = M1[%#y%?+] = %x"}, {"LDBU",0x2a,0,1,1,"%l = M1[%#y+%#z] = %#x"}, {"LDBUI",0x29,0,1,1,"%l = M1[%#y%?+] = %#x"}, {"LDW",0x2a,0,1,1,"%l = M2[%#y+%#z] = %x"}, {"LDWI",0x29,0,1,1,"%l = M2[%#y%?+] = %x"}, {"LDWU",0x2a,0,1,1,"%l = M2[%#y+%#z] = %#x"}, {"LDWUI",0x29,0,1,1,"%l = M2[%#y%?+] = %#x"}, {"LDT",0x2a,0,1,1,"%l = M4[%#y+%#z] = %x"}, {"LDTI",0x29,0,1,1,"%l = M4[%#y%?+] = %x"}, {"LDTU",0x2a,0,1,1,"%l = M4[%#y+%#z] = %#x"}, {"LDTUI",0x29,0,1,1,"%l = M4[%#y%?+] = %#x"}, {"LDO",0x2a,0,1,1,"%l = M8[%#y+%#z] = %x"}, {"LDOI",0x29,0,1,1,"%l = M8[%#y%?+] = %x"}, {"LDOU",0x2a,0,1,1,"%l = M8[%#y+%#z] = %#x"}, {"LDOUI",0x29,0,1,1,"%l = M8[%#y%?+] = %#x"}, {"LDSF",0x2a,0,1,1,"%l = (M4[%#y+%#z]) = %.x"}, {"LDSFI",0x29,0,1,1,"%l = (M4[%#y%?+]) = %.x"}, {"LDHT",0x2a,0,1,1,"%l = M4[%#y+%#z]<<32 = %#x"}, {"LDHTI",0x29,0,1,1,"%l = M4[%#y%?+]<<32 = %#x"}, {"CSWAP",0x3a,0,2,2,"%l = [M8[%#y+%#z]==%a] = %x, %r"}, {"CSWAPI",0x39,0,2,2,"%l = [M8[%#y%?+]==%a] = %x, %r"}, {"LDUNC",0x2a,0,1,1,"%l = M8[%#y+%#z] = %#x"}, {"LDUNCI",0x29,0,1,1,"%l = M8[%#y%?+] = %#x"}, {"LDVTS",0x2a,0,0,1,""}, {"LDVTSI",0x29,0,0,1,""}, {"PRELD",0x0a,0,0,1,"[%#y+%#z .. %#x]"}, {"PRELDI",0x09,0,0,1,"[%#y%?+ .. %#x]"}, {"PREGO",0x0a,0,0,1,"[%#y+%#z .. %#x]"}, {"PREGOI",0x09,0,0,1,"[%#y%?+ .. %#x]"}, {"GO",0x2a,0,0,3,"%l = %#x, -> %#y+%#z"}, {"GOI",0x29,0,0,3,"%l = %#x, -> %#y%?+"}, {"STB",0x1a,0,1,1,"M1[%#y+%#z] = %b, M8[%#w]=%#a"}, {"STBI",0x19,0,1,1,"M1[%#y%?+] = %b, M8[%#w]=%#a"}, {"STBU",0x1a,0,1,1,"M1[%#y+%#z] = %#b, M8[%#w]=%#a"}, {"STBUI",0x19,0,1,1,"M1[%#y%?+] = %#b, M8[%#w]=%#a"}, {"STW",0x1a,0,1,1,"M2[%#y+%#z] = %b, M8[%#w]=%#a"}, {"STWI",0x19,0,1,1,"M2[%#y%?+] = %b, M8[%#w]=%#a"}, {"STWU",0x1a,0,1,1,"M2[%#y+%#z] = %#b, M8[%#w]=%#a"}, {"STWUI",0x19,0,1,1,"M2[%#y%?+] = %#b, M8[%#w]=%#a"}, {"STT",0x1a,0,1,1,"M4[%#y+%#z] = %b, M8[%#w]=%#a"}, {"STTI",0x19,0,1,1,"M4[%#y%?+] = %b, M8[%#w]=%#a"}, {"STTU",0x1a,0,1,1,"M4[%#y+%#z] = %#b, M8[%#w]=%#a"}, {"STTUI",0x19,0,1,1,"M4[%#y%?+] = %#b, M8[%#w]=%#a"}, {"STO",0x1a,0,1,1,"M8[%#y+%#z] = %b"}, {"STOI",0x19,0,1,1,"M8[%#y%?+] = %b"}, {"STOU",0x1a,0,1,1,"M8[%#y+%#z] = %#b"}, {"STOUI",0x19,0,1,1,"M8[%#y%?+] = %#b"}, {"STSF",0x1a,0,1,1,"%(M4[%#y+%#z]%) = %.b, M8[%#w]=%#a"}, {"STSFI",0x19,0,1,1,"%(M4[%#y%?+]%) = %.b, M8[%#w]=%#a"}, {"STHT",0x1a,0,1,1,"M4[%#y+%#z] = %#b>>32, M8[%#w]=%#a"}, {"STHTI",0x19,0,1,1,"M4[%#y%?+] = %#b>>32, M8[%#w]=%#a"}, {"STCO",0x0a,0,1,1,"M8[%#y+%#z] = %b"}, {"STCOI",0x09,0,1,1,"M8[%#y%?+] = %b"}, {"STUNC",0x1a,0,1,1,"M8[%#y+%#z] = %#b"}, {"STUNCI",0x19,0,1,1,"M8[%#y%?+] = %#b"}, {"SYNCD",0x0a,0,0,1,"[%#y+%#z .. %#x]"}, {"SYNCDI",0x09,0,0,1,"[%#y%?+ .. %#x]"}, {"PREST",0x0a,0,0,1,"[%#y+%#z .. %#x]"}, {"PRESTI",0x09,0,0,1,"[%#y%?+ .. %#x]"}, {"SYNCID",0x0a,0,0,1,"[%#y+%#z .. %#x]"}, {"SYNCIDI",0x09,0,0,1,"[%#y%?+ .. %#x]"}, {"PUSHGO",0x8a,0,0,3,"%lrO=%#b, rL=%a, rJ=%#x, -> %#y+%#z"}, {"PUSHGOI",0x89,0,0,3,"%lrO=%#b, rL=%a, rJ=%#x, -> %#y%?+"} /*:68*/ #line 1458 "mmix-sim.w" , /*69:*/ #line 1659 "mmix-sim.w" {"OR",0x2a,0,0,1,"%l = %#y | %#z = %#x"}, {"ORI",0x29,0,0,1,"%l = %#y | %z = %#x"}, {"ORN",0x2a,0,0,1,"%l = %#y |~ %#z = %#x"}, {"ORNI",0x29,0,0,1,"%l = %#y |~ %z = %#x"}, {"NOR",0x2a,0,0,1,"%l = %#y ~| %#z = %#x"}, {"NORI",0x29,0,0,1,"%l = %#y ~| %z = %#x"}, {"XOR",0x2a,0,0,1,"%l = %#y ^ %#z = %#x"}, {"XORI",0x29,0,0,1,"%l = %#y ^ %z = %#x"}, {"AND",0x2a,0,0,1,"%l = %#y & %#z = %#x"}, {"ANDI",0x29,0,0,1,"%l = %#y & %z = %#x"}, {"ANDN",0x2a,0,0,1,"%l = %#y \\ %#z = %#x"}, {"ANDNI",0x29,0,0,1,"%l = %#y \\ %z = %#x"}, {"NAND",0x2a,0,0,1,"%l = %#y ~& %#z = %#x"}, {"NANDI",0x29,0,0,1,"%l = %#y ~& %z = %#x"}, {"NXOR",0x2a,0,0,1,"%l = %#y ~^ %#z = %#x"}, {"NXORI",0x29,0,0,1,"%l = %#y ~^ %z = %#x"}, {"BDIF",0x2a,0,0,1,"%l = %#y bdif %#z = %#x"}, {"BDIFI",0x29,0,0,1,"%l = %#y bdif %z = %#x"}, {"WDIF",0x2a,0,0,1,"%l = %#y wdif %#z = %#x"}, {"WDIFI",0x29,0,0,1,"%l = %#y wdif %z = %#x"}, {"TDIF",0x2a,0,0,1,"%l = %#y tdif %#z = %#x"}, {"TDIFI",0x29,0,0,1,"%l = %#y tdif %z = %#x"}, {"ODIF",0x2a,0,0,1,"%l = %#y odif %#z = %#x"}, {"ODIFI",0x29,0,0,1,"%l = %#y odif %z = %#x"}, {"MUX",0x2a,rM,0,1,"%l = %#b? %#y: %#z = %#x"}, {"MUXI",0x29,rM,0,1,"%l = %#b? %#y: %z = %#x"}, {"SADD",0x2a,0,0,1,"%l = nu(%#y\\%#z) = %x"}, {"SADDI",0x29,0,0,1,"%l = nu(%#y%?\\) = %x"}, {"MOR",0x2a,0,0,1,"%l = %#y mor %#z = %#x"}, {"MORI",0x29,0,0,1,"%l = %#y mor %z = %#x"}, {"MXOR",0x2a,0,0,1,"%l = %#y mxor %#z = %#x"}, {"MXORI",0x29,0,0,1,"%l = %#y mxor %z = %#x"}, {"SETH",0x20,0,0,1,"%l = %#z"}, {"SETMH",0x20,0,0,1,"%l = %#z"}, {"SETML",0x20,0,0,1,"%l = %#z"}, {"SETL",0x20,0,0,1,"%l = %#z"}, {"INCH",0x30,0,0,1,"%l = %#y + %#z = %#x"}, {"INCMH",0x30,0,0,1,"%l = %#y + %#z = %#x"}, {"INCML",0x30,0,0,1,"%l = %#y + %#z = %#x"}, {"INCL",0x30,0,0,1,"%l = %#y + %#z = %#x"}, {"ORH",0x30,0,0,1,"%l = %#y | %#z = %#x"}, {"ORMH",0x30,0,0,1,"%l = %#y | %#z = %#x"}, {"ORML",0x30,0,0,1,"%l = %#y | %#z = %#x"}, {"ORL",0x30,0,0,1,"%l = %#y | %#z = %#x"}, {"ANDNH",0x30,0,0,1,"%l = %#y \\ %#z = %#x"}, {"ANDNMH",0x30,0,0,1,"%l = %#y \\ %#z = %#x"}, {"ANDNML",0x30,0,0,1,"%l = %#y \\ %#z = %#x"}, {"ANDNL",0x30,0,0,1,"%l = %#y \\ %#z = %#x"}, {"JMP",0x40,0,0,1,"-> %#z"}, {"JMPB",0x40,0,0,1,"-> %#z"}, {"PUSHJ",0xc0,0,0,1,"%lrO=%#b, rL=%a, rJ=%#x, -> %#z"}, {"PUSHJB",0xc0,0,0,1,"%lrO=%#b, rL=%a, rJ=%#x, -> %#z"}, {"GETA",0x60,0,0,1,"%l = %#z"}, {"GETAB",0x60,0,0,1,"%l = %#z"}, {"PUT",0x02,0,0,1,"%s = %r"}, {"PUTI",0x01,0,0,1,"%s = %r"}, {"POP",0x80,rJ,0,3,"%lrL=%a, rO=%#b, -> %#y%?+"}, {"RESUME",0x00,0,0,5,"{%#b} -> %#z"}, {"SAVE",0x20,0,20,1,"%l = %#x"}, {"UNSAVE",0x82,0,20,1,"%#z: rG=%x, ..., rL=%a"}, {"SYNC",0x01,0,0,1,""}, {"SWYM",0x00,0,0,1,""}, {"GET",0x20,0,0,1,"%l = %s = %#x"}, {"TRIP",0x0a,255,0,5,"rY=%#y, rZ=%#z, rB=%#b, g[255]=0"} /*:69*/ #line 1459 "mmix-sim.w" }; /*:65*//*76:*/ #line 1775 "mmix-sim.w" octa g[256]; octa*l; int lring_size; int lring_mask; int S; /*:76*//*110:*/ #line 2402 "mmix-sim.w" char arg_count[]= {1,3,1,3,3,3,3,2,2,2,1}; char*trap_format[]= { "Halt(%z)", "$255 = Fopen(%!z,M8[%#b]=%#q,M8[%#a]=%p) = %x", "$255 = Fclose(%!z) = %x", "$255 = Fread(%!z,M8[%#b]=%#q,M8[%#a]=%p) = %x", "$255 = Fgets(%!z,M8[%#b]=%#q,M8[%#a]=%p) = %x", "$255 = Fgetws(%!z,M8[%#b]=%#q,M8[%#a]=%p) = %x", "$255 = Fwrite(%!z,M8[%#b]=%#q,M8[%#a]=%p) = %x", "$255 = Fputs(%!z,%#b) = %x", "$255 = Fputws(%!z,%#b) = %x", "$255 = Fseek(%!z,%b) = %x", "$255 = Ftell(%!z) = %x"}; /*:110*//*113:*/ #line 2430 "mmix-sim.w" extern void mmix_io_init ARGS((void)); extern octa mmix_fopen ARGS((unsigned char,octa,octa)); extern octa mmix_fclose ARGS((unsigned char)); extern octa mmix_fread ARGS((unsigned char,octa,octa)); extern octa mmix_fgets ARGS((unsigned char,octa,octa)); extern octa mmix_fgetws ARGS((unsigned char,octa,octa)); extern octa mmix_fwrite ARGS((unsigned char,octa,octa)); extern octa mmix_fputs ARGS((unsigned char,octa)); extern octa mmix_fputws ARGS((unsigned char,octa)); extern octa mmix_fseek ARGS((unsigned char,octa)); extern octa mmix_ftell ARGS((unsigned char)); extern void print_trip_warning ARGS((int,octa)); extern void mmix_fake_stdin ARGS((FILE*)); /*:113*//*121:*/ #line 2563 "mmix-sim.w" char stdin_buf[256]; char*stdin_buf_start; char*stdin_buf_end; /*:121*//*129:*/ #line 2665 "mmix-sim.w" bool showing_stats; bool just_traced; /*:129*//*139:*/ #line 2835 "mmix-sim.w" char left_paren[]= {0,'[','^','_','('}; char right_paren[]= {0,']','^','_',')'}; char switchable_string[48]; char lhs[32]; int good_guesses,bad_guesses; /*:139*//*144:*/ #line 2970 "mmix-sim.w" char*myself; char**cur_arg; bool interrupt; bool profiling; FILE*fake_stdin; FILE*dump_file; char*usage_help[]= { " with these options: (=decimal number, =hex number)\n", "-t trace each instruction the first n times\n", "-e trace each instruction with an exception matching x\n", "-r trace hidden details of the register stack\n", "-l list source lines when tracing, filling gaps <= n\n", "-s show statistics after each traced instruction\n", "-P print a profile when simulation ends\n", "-L list source lines with the profile\n", "-v be verbose: show almost everything\n", "-q be quiet: show only the simulated standard output\n", "-i run interactively (prompt for online commands)\n", "-I interact, but only after the program halts\n", "-b change the buffer size for source lines\n", "-c change the cyclic local register ring size\n", "-f use given file to simulate standard input\n", "-D dump a file for use by other simulators\n", ""}; char*interactive_help[]= { "The interactive commands are:\n", " trace one instruction\n", "n trace one instruction\n", "c continue until halt or breakpoint\n", "q quit the simulation\n", "s show current statistics\n", "l set and/or show local register in format t\n", "g set and/or show global register in format t\n", "rA set and/or show register rA in format t\n", "$ set and/or show dynamic register in format t\n", "M set and/or show memory octabyte in format t\n", "+ set and/or show n additional octabytes in format t\n", " is ! (decimal) or . (floating) or # (hex) or \" (string)\n", " or (previous ) or = (change value)\n", "@ go to location x\n", "b[rwx] set or reset breakpoint at location x\n", "t trace location x\n", "u untrace location x\n", "T set current segment to Text_Segment\n", "D set current segment to Data_Segment\n", "P set current segment to Pool_Segment\n", "S set current segment to Stack_Segment\n", "B show all current breakpoints and tracepoints\n", "i insert commands from file\n", "-