unsigned short limit_test ( void ) { unsigned short ra; short sa; for(ra=0;;ra++) if(ult(ra,7)==0) break; hexstring(ra); if(ra!=7) return(1); for(ra=0xF000;;ra++) if(ult(ra,0xF007)==0) break; hexstring(ra); if(ra!=0xF007) return(1); for(sa=-7;;sa++) if(slt(sa,7)==0) break; hexstring(sa); if(sa!=7) return(1); for(sa=-17;;sa++) if(slt(sa,-7)==0) break; hexstring(sa); if(sa!=-7) return(1); for(ra=0;;ra++) if(ulte(ra,7)==0) break; hexstring(ra); if(ra!=8) return(1); for(ra=0xF000;;ra++) if(ulte(ra,0xF007)==0) break; hexstring(ra); if(ra!=0xF008) return(1); for(ra=0xF000;;ra++) if(ulte(ra,7)==0) break; hexstring(ra); if(ra!=0xF000) return(1); for(sa=-7;;sa++) if(slte(sa,7)==0) break; hexstring(sa); if(sa!=8) return(1); for(sa=-17;;sa++) if(slte(sa,-7)==0) break; hexstring(sa); if(sa!=-6) return(1); for(ra=0;;ra++) if(ugt(ra,7)) break; hexstring(ra); if(ra!=8) return(1); for(ra=0xF000;;ra++) if(ugt(ra,0xF007)) break; hexstring(ra); if(ra!=0xF008) return(1); for(ra=0;;ra++) if(ugte(ra,7)) break; hexstring(ra); if(ra!=7) return(1); for(ra=0xF000;;ra++) if(ugte(ra,0xF007)) break; hexstring(ra); if(ra!=0xF007) return(1); return(0); }
void alu_unit(int s, int t) { struct ins* i = CPU.pipeline[1]; int opc = i->opcode; short c = i->c; if(opc) { if(opc == _addi) addi(s, c); else if(opc == _halt) printf("encounter halt\n"); else if(is_load(opc) || is_store(opc)) load_store(s, c); else if(opc == _lui) lui(c); else if(opc == _andi) andi(s, c); else if(opc == _ori) ori(s, c); else if(opc == _nori) nori(s, c); else if(opc == _slti) slti(s, c); } else { int func = i->func; int shamt = i->shamt; if(func == _add) add(0, s, t); else if(func == _sub) add(1, s, t); else if(func == _and) and(0, s, t); else if(func == _or) or(0, s, t); else if(func == _xor) or(1, s, t); else if(func == _nor) or(2, s, t); else if(func == _nand) and(1, s, t); else if(func == _slt) slt(s, t); else if(func == _sll) sll(t, shamt); else if(func == _srl) sr(0, t, shamt); else if(func == _sra) sr(1, t, shamt); } }
int exe(FILE* program) //program指向存有待执行程序机器码的文件 { char* tmp_instru=(char*)malloc(33*sizeof(char)); //读机器码 programTail=programHead; while(fscanf(program,"%s",tmp_instru)!=EOF) { instru=0; int i=0; unsigned j=1; for(i=31;i>=0;i--) { if(tmp_instru[i]=='1') { instru+=j; j*=2; } else { j*=2; } }//将机器码转为unsi unsigned char* tmp_R=&instru; for(i=0;i<4;i++) { writeMymemory(programTail+i,tmp_R+i);//装载指令 } programTail+=4;//最后一条指令的下一条指令的地址,用来判断程序是否执行完 } pcShort=programHead; pc=pcShort; while(pcShort!=programTail) { instru=0; //指令寄存器清零 unsigned char* tmp_R=&instru; unsigned short addr=addrToMyAddr(pc); int i; for(i=0;i<4;i++) { readMymemory(addr+i,tmp_R+i);//取指令 } unsigned tmp=instru>>26;//得到指令op //printf("the op is : %u\n",tmp); unsigned numRs=0,numRt=0,numRd=0,numFs=0,numFt=0,numFd=0,tmp_fuc=0; switch(tmp) { case 0x00000023: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=lw(pc); break; case 0x0000002B: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=sw(pc); break; case 0x00000008: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=addi(pc); break; case 0x00000009: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=addiu(pc); break; case 0x0000000A: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=slti(pc); break; case 0x0000000B: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=sltiu(pc); break; case 0x0000000C: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=andi(pc); break; case 0x0000000D: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=ori(pc); break; case 0x0000000E: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=xori(pc); break; case 0x00000024: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=lbu(pc); break; case 0x00000020: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=lb(pc); break; case 0x00000028: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=sb(pc); break; case 0x0000000F: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=lui(pc); break; case 0x00000004: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=beq(pc); break; case 0x00000005: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; //printf("%u,%u,%u,%u\n",numRt,numRs,*RS1,*RS2); lig=instru<<16>>16; // printf("%u\n",lig); pc=bne(pc); break; case 0x00000006: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=blez(pc); break; case 0x00000007: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=bgtz(pc); break; case 0x00000001: numRs=instru<<6>>27; numRt=instru<<11>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; lig=instru<<16>>16; pc=bltz(pc); break; case 0x00000002: pc=j(pc); break; case 0x00000003: pc=jal(pc); break; case 0x00000000: numRs=instru<<6>>27; numRt=instru<<11>>27; numRd=instru<<16>>27; RS1=myRegister+numRt; RS2=myRegister+numRs; RD=myRegister+numRd; tmp_fuc=instru%64; switch(tmp_fuc) { case 32: pc=add(pc); break; case 33: pc=addu(pc); break; case 34: pc=sub(pc); break; case 35: pc=subu(pc); break; case 24: pc=mul(pc); break; case 25: pc=mulu(pc); break; case 26: pc=myDiv(pc); break; case 27: pc=divu(pc); break; case 42: pc=slt(pc); break; case 43: pc=sltu(pc); break; case 36: pc=myAnd(pc); break; case 37: pc=myOr(pc); break; case 39: pc=nor(pc); break; case 40: pc=myXor(pc); break; case 8: pc=jr(pc); break; case 9: pc=jalr(pc); break; case 0: pc=nop(pc); break; case 16: pc=mfhi(pc); break; case 18: pc=mflo(pc); break; default: break; } break; case 0x00000010: numRt=instru<<11>>27; numRd=instru<<16>>27; RS1=myRegister+numRt; if(numRd==14) { pc=mfepc(pc); } else if(numRd==13) { pc=mfco(pc); } else return -1; break; case 0x00000031: numRs=instru<<6>>27; numFt=instru<<11>>27; RS2=myRegister+numRs; FS1=myFloatReg+numFt; lig=instru<<16>>16; pc=lwc1(pc); //printf("/********\nL.S %u %u\n****************/\n",numFt,numRs); break; case 0x0000001F: numRs=instru<<6>>27; numFt=instru<<11>>27; RS2=myRegister+numRs; FS1=myFloatReg+numFt; lig=instru<<16>>16; pc=S_D(pc); //printf("/********\nL.D %u %u\n****************/\n",numFt,numRs); break; case 0x0000001E: numRs=instru<<6>>27; numFt=instru<<11>>27; RS2=myRegister+numRs; FS1=myFloatReg+numFt; lig=instru<<16>>16; //printf("/********\nS.D %u %u\n****************/\n",numFt,numRs); pc=S_D(pc); break; case 0x00000039: numRs=instru<<6>>27; numFt=instru<<11>>27; RS2=myRegister+numRs; FS1=myFloatReg+numFt; lig=instru<<16>>16; //printf("/********\nS.S %u %u\n****************/\n",numFt,numRs); pc=swc1(pc); break; case 0x00000011: numFt=instru<<11>>27; numFs=instru<<16>>27; numFd=instru<<21>>27; FS1=myFloatReg+numFt; FS2=myFloatReg+numFs; FD=myFloatReg+numFd; numRs=instru<<6>>27; tmp_fuc=instru%64; //printf("%u %u\n",tmp_fuc,numRs); if(numRs==0) { switch(tmp_fuc) { case 0: pc=add_s(pc); break; case 1: pc=sub_s(pc); break; case 2: pc=mul_s(pc); case 3: pc=div_s(pc); default: break; } } else if(numRs==1) { switch(tmp_fuc) { case 0: pc=add_d(pc); //printf("/****************\nADD.D %u %u %u\n*****************/\n",numFd,numFt,numFs); break; case 1: pc=sub_d(pc); break; case 2: pc=mul_d(pc); case 3: pc=div_d(pc); default: break; } } default:break; } pcShort=pc%0x00010000; //printf("%u %u\n",pc,pcShort); //printf("%u %u\n",pcShort,programTail); } return 0; }
void simulate_MainWindow::simulate() { currInstr=instrList[PC/4]; currBin=binList[PC/4]; vector<string> result; string temp=currInstr.toStdString(); string_split(temp,result); coutString=""; RD=RS=RT=immediate=address=0; v0=v1=v2=v3="None"; v0=result[0]; v1=result[1]; printf("v0=%s\nv1=%s\n",v0.c_str(),v1.c_str()); if(v0=="jr"||v0=="j"||v0=="jal") // 2 parametes { if(v0=="jr") { jr(); } else if(v0=="j") j(); else if(v0=="jal") jal(); } else if(v0=="lui") // 3 parameters { v2=result[2]; lui(); } else // 4 parameters { v2=result[2]; v3=result[3]; if(v0=="add") add(); else if(v0=="addu") addu(); else if(v0=="sub") sub(); else if(v0=="subu") subu(); else if(v0=="and") and_funct(); else if(v0=="or") or_funct(); else if(v0=="xor") xor_funct(); else if(v0=="nor") nor(); else if(v0=="slt") slt(); else if(v0=="sltu") sltu(); else if(v0=="sll") sll(); else if(v0=="srl") srl(); else if(v0=="sllv") sllv(); else if(v0=="srlv") srlv(); else if(v0=="srav") srav(); else if(v0=="addi") addi(); else if(v0=="addiu") addiu(); else if(v0=="andi") andi(); else if(v0=="ori") ori(); else if(v0=="xori") xori(); else if(v0=="sw") sw(); else if(v0=="lw") lw(); else if(v0=="beq") beq(); else if(v0=="bne") bne(); else if(v0=="slti") slti(); else if(v0=="sltiu") sltiu(); } display_all(); }
void ConcurrentMarkThread::run() { initialize_in_thread(); _vtime_start = os::elapsedVTime(); wait_for_universe_init(); G1CollectedHeap* g1h = G1CollectedHeap::heap(); G1CollectorPolicy* g1_policy = g1h->g1_policy(); G1MMUTracker *mmu_tracker = g1_policy->mmu_tracker(); Thread *current_thread = Thread::current(); while (!_should_terminate) { // wait until started is set. sleepBeforeNextCycle(); { ResourceMark rm; HandleMark hm; double cycle_start = os::elapsedVTime(); double mark_start_sec = os::elapsedTime(); char verbose_str[128]; if (PrintGC) { gclog_or_tty->date_stamp(PrintGCDateStamps); gclog_or_tty->stamp(PrintGCTimeStamps); gclog_or_tty->print_cr("[GC concurrent-mark-start]"); } if (!g1_policy->in_young_gc_mode()) { // this ensures the flag is not set if we bail out of the marking // cycle; normally the flag is cleared immediately after cleanup g1h->set_marking_complete(); if (g1_policy->adaptive_young_list_length()) { double now = os::elapsedTime(); double init_prediction_ms = g1_policy->predict_init_time_ms(); jlong sleep_time_ms = mmu_tracker->when_ms(now, init_prediction_ms); os::sleep(current_thread, sleep_time_ms, false); } // We don't have to skip here if we've been asked to restart, because // in the worst case we just enqueue a new VM operation to start a // marking. Note that the init operation resets has_aborted() CMCheckpointRootsInitialClosure init_cl(_cm); strcpy(verbose_str, "GC initial-mark"); VM_CGC_Operation op(&init_cl, verbose_str); VMThread::execute(&op); } int iter = 0; do { iter++; if (!cm()->has_aborted()) { _cm->markFromRoots(); } double mark_end_time = os::elapsedVTime(); double mark_end_sec = os::elapsedTime(); _vtime_mark_accum += (mark_end_time - cycle_start); if (!cm()->has_aborted()) { if (g1_policy->adaptive_young_list_length()) { double now = os::elapsedTime(); double remark_prediction_ms = g1_policy->predict_remark_time_ms(); jlong sleep_time_ms = mmu_tracker->when_ms(now, remark_prediction_ms); os::sleep(current_thread, sleep_time_ms, false); } if (PrintGC) { gclog_or_tty->date_stamp(PrintGCDateStamps); gclog_or_tty->stamp(PrintGCTimeStamps); gclog_or_tty->print_cr("[GC concurrent-mark-end, %1.7lf sec]", mark_end_sec - mark_start_sec); } CMCheckpointRootsFinalClosure final_cl(_cm); sprintf(verbose_str, "GC remark"); VM_CGC_Operation op(&final_cl, verbose_str); VMThread::execute(&op); } if (cm()->restart_for_overflow() && G1TraceMarkStackOverflow) { gclog_or_tty->print_cr("Restarting conc marking because of MS overflow " "in remark (restart #%d).", iter); } if (cm()->restart_for_overflow()) { if (PrintGC) { gclog_or_tty->date_stamp(PrintGCDateStamps); gclog_or_tty->stamp(PrintGCTimeStamps); gclog_or_tty->print_cr("[GC concurrent-mark-restart-for-overflow]"); } } } while (cm()->restart_for_overflow()); double counting_start_time = os::elapsedVTime(); // YSR: These look dubious (i.e. redundant) !!! FIX ME slt()->manipulatePLL(SurrogateLockerThread::acquirePLL); slt()->manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL); if (!cm()->has_aborted()) { double count_start_sec = os::elapsedTime(); if (PrintGC) { gclog_or_tty->date_stamp(PrintGCDateStamps); gclog_or_tty->stamp(PrintGCTimeStamps); gclog_or_tty->print_cr("[GC concurrent-count-start]"); } _sts.join(); _cm->calcDesiredRegions(); _sts.leave(); if (!cm()->has_aborted()) { double count_end_sec = os::elapsedTime(); if (PrintGC) { gclog_or_tty->date_stamp(PrintGCDateStamps); gclog_or_tty->stamp(PrintGCTimeStamps); gclog_or_tty->print_cr("[GC concurrent-count-end, %1.7lf]", count_end_sec - count_start_sec); } } } double end_time = os::elapsedVTime(); _vtime_count_accum += (end_time - counting_start_time); // Update the total virtual time before doing this, since it will try // to measure it to get the vtime for this marking. We purposely // neglect the presumably-short "completeCleanup" phase here. _vtime_accum = (end_time - _vtime_start); if (!cm()->has_aborted()) { if (g1_policy->adaptive_young_list_length()) { double now = os::elapsedTime(); double cleanup_prediction_ms = g1_policy->predict_cleanup_time_ms(); jlong sleep_time_ms = mmu_tracker->when_ms(now, cleanup_prediction_ms); os::sleep(current_thread, sleep_time_ms, false); } CMCleanUp cl_cl(_cm); sprintf(verbose_str, "GC cleanup"); VM_CGC_Operation op(&cl_cl, verbose_str); VMThread::execute(&op); } else { g1h->set_marking_complete(); } // Check if cleanup set the free_regions_coming flag. If it // hasn't, we can just skip the next step. if (g1h->free_regions_coming()) { // The following will finish freeing up any regions that we // found to be empty during cleanup. We'll do this part // without joining the suspendible set. If an evacuation pause // takes places, then we would carry on freeing regions in // case they are needed by the pause. If a Full GC takes // places, it would wait for us to process the regions // reclaimed by cleanup. double cleanup_start_sec = os::elapsedTime(); if (PrintGC) { gclog_or_tty->date_stamp(PrintGCDateStamps); gclog_or_tty->stamp(PrintGCTimeStamps); gclog_or_tty->print_cr("[GC concurrent-cleanup-start]"); } // Now do the remainder of the cleanup operation. _cm->completeCleanup(); // Notify anyone who's waiting that there are no more free // regions coming. We have to do this before we join the STS, // otherwise we might deadlock: a GC worker could be blocked // waiting for the notification whereas this thread will be // blocked for the pause to finish while it's trying to join // the STS, which is conditional on the GC workers finishing. g1h->reset_free_regions_coming(); _sts.join(); g1_policy->record_concurrent_mark_cleanup_completed(); _sts.leave(); double cleanup_end_sec = os::elapsedTime(); if (PrintGC) { gclog_or_tty->date_stamp(PrintGCDateStamps); gclog_or_tty->stamp(PrintGCTimeStamps); gclog_or_tty->print_cr("[GC concurrent-cleanup-end, %1.7lf]", cleanup_end_sec - cleanup_start_sec); } } guarantee(cm()->cleanup_list_is_empty(), "at this point there should be no regions on the cleanup list"); if (cm()->has_aborted()) { if (PrintGC) { gclog_or_tty->date_stamp(PrintGCDateStamps); gclog_or_tty->stamp(PrintGCTimeStamps); gclog_or_tty->print_cr("[GC concurrent-mark-abort]"); } } // we now want to allow clearing of the marking bitmap to be // suspended by a collection pause. _sts.join(); _cm->clearNextBitmap(); _sts.leave(); } // Update the number of full collections that have been // completed. This will also notify the FullGCCount_lock in case a // Java thread is waiting for a full GC to happen (e.g., it // called System.gc() with +ExplicitGCInvokesConcurrent). _sts.join(); g1h->increment_full_collections_completed(true /* concurrent */); _sts.leave(); } assert(_should_terminate, "just checking"); terminate(); }
void Pince::in_state_func() { switch (state) { case RANGE_DEPART : a1(); scv(); slr(); break; case TAPE_VERTICAL : a1(); scv(); slt(); break; case INTERMEDIAIRE_SORTIE : set_time_out(400, trigger_to_be); a1(); slo(); scv(); break; case HORIZ_VERT : a1(); slo(); scn(); break; case NOMINAL_VIDE : set_time_out(500, trigger_to_be); a0(); slo(); scn(); break; case ACTIF_TORCHE : a0(); slo(); scn(); break; case PRISE_TORCHE : Serial.println('# PRISE'); a0(); slf(); scn(); break; case ACTIF_FEU : a0(); slo(); scn(); break; case PRISE_FEU : Serial.println('# PRISE'); set_time_out(500, TIME_OUT); a0(); slf(); scn(); break; case WAIT_COOL_OK : break; case MONTE_COOL : set_time_out(800, TIME_OUT); a1(); slf(); scn(); break; case MONTE_COOL2 : a1(); slf(); scn(); break; case RETOURNE_COOL_N : set_time_out(500, TIME_OUT); a1(); slf(); scr(); break; case DESCEND_COOL_N : a0(); slf(); scr(); break; case POSE_COOL_N : set_time_out(500, TIME_OUT); a0(); slo(); scr(); break; case INT1_COOL_N : set_time_out(500, TIME_OUT); a1(); slo(); scr(); break; case INT2_COOL_N : set_time_out(500, TIME_OUT); a1(); slf(); scr(); break; case INT3_COOL_N : set_time_out(500, TIME_OUT); a1(); slf(); scn(); break; case INT_RANGE : a1(); slo(); break; case INT2_RANGE : set_time_out(10, trigger_to_be); a1(); slo(); break; } }
void execution(int index){ if(test==1) printf("enter EX, with index=%d\n",index); if(index==0 || index==34){ //NOP or HALT return; } /**R-type instructions**/ else if(index==1){ add(RS,RT,RD); } else if(index==2){ addu(RS,RT,RD); } else if(index==3){ sub(RS,RT,RD); } else if(index==4){ and(RS,RT,RD); } else if(index==5){ or(RS,RT,RD); } else if(index==6){ xor(RS,RT,RD); } else if(index==7){ nor(RS,RT,RD); } else if(index==8){ nand(RS,RT,RD); } else if(index==9){ slt(RS,RT,RD); } else if(index==10){ sll(RT,RD,SHAMT); } else if(index==11){ srl(RT,RD,SHAMT); } else if(index==12){ sra(RT,RD,SHAMT); } /**J-type instructions**/ /*else if(index==13){ jr(RS); } else if(index==14){ jj(C); } else if(index==15){ jal(C); }*/ /**I-type instructions**/ else if(index==16){ addi(RS,RT,C); } else if(index==17){ addiu(RS,RT,C); } else if(index==18){ lw(RS,RT,signedC); } else if(index==19){ lh(RS,RT,signedC); } else if(index==20){ lhu(RS,RT,C); } else if(index==21){ lb(RS,RT,signedC); } else if(index==22){ lbu(RS,RT,C); } else if(index==23){ sw(RS,RT,signedC); } else if(index==24){ sh(RS,RT,signedC); } else if(index==25){ sb(RS,RT,signedC); } else if(index==26){ lui(RT,C); } else if(index==27){ andi(RS,RT,C); } else if(index==28){ or(RS,RT,C); } else if(index==29){ nor(RS,RT,C); } else if(index==30){ slti(RS,RT,C); } /*else if(index==31){ beq(RS,RT,signedC); } else if(index==32){ bne(RS,RT,signedC); } else if(index==33){ bgtz(RS,signedC); }*/ else{ if(test==1) printf("this is error instruction or is done in ID\n"); } EX_prev=index; DM_index=index; }
void read_file(char * filename) { fp = fopen(filename, "r"); char * line = malloc(sizeof(char) * 255); while (fgets(line,255,fp) != NULL) { char * buf[] = {" "," "," "," "}; char * check = strtok(line, " "); int i = 0; while (check != NULL) { if (check != NULL) { buf[i] = malloc(strlen(check) + 1); strcpy(buf[i],check); } check = strtok(NULL, " "); i++; } if(strcmp(buf[0],"addu") == 0) { addu(trim(buf[2], ','),trim(buf[3], ','),trim(buf[1], '\n')); } else if (strcmp(buf[0],"subu") == 0) { subu(trim(buf[2], ','),trim(buf[3], ','),trim(buf[1], '\n')); } else if(strcmp(buf[0],"slt") ==0) { slt(trim(buf[2], ','),trim(buf[3], ','),trim(buf[1], '\n')); } else if(strcmp(buf[0],"and") == 0) { and(trim(buf[2], ','),trim(buf[3], ','),trim(buf[1], '\n')); } else if(strcmp(buf[0],"or") == 0) { or(trim(buf[2], ','),trim(buf[3], ','),trim(buf[1], '\n')); } else if(strcmp(buf[0],"lw") == 0) { lw(rs_I(buf[2]), trim(buf[1], ','), trim(buf[2], '(')); } else if (strcmp(buf[0],"sw") == 0) { sw(rs_I(buf[2]), trim(buf[1], ','), trim(buf[2], '(')); } else if(strcmp(buf[0],"bne") == 0) { bne(trim(buf[2], ','),trim(buf[1], ','),trim(buf[3], 'j')); } else if(strcmp(buf[0],"j")== 0) { j(trim(buf[1], 'j')); } } fclose(fp); printf("End Scan\n"); }