예제 #1
0
t_stat doFaultInstructionPair(DCDstruct *i, word24 fltAddress)
{
    // XXX stolen from xed instruction
    
    DCDstruct _xip;   // our decoded instruction struct
    EISstruct _eis;

    word36 insPair[2];
    Read2(i, fltAddress, &insPair[0], &insPair[1], InstructionFetch, 0);
    
    _xip.IWB = insPair[0];
    _xip.e = &_eis;
    
    DCDstruct *xec = decodeInstruction(insPair[0], &_xip);    // fetch instruction into current instruction
    
    t_stat ret = executeInstruction(xec);
    
    if (ret)
        return (ret);
    
    _xip.IWB = insPair[1];
    _xip.e = &_eis;
    
    xec = decodeInstruction(insPair[1], &_xip);               // fetch instruction into current instruction
    
    ret = executeInstruction(xec);
    
    //if (ret)
    //    return (ret);
    //
    //return SCPE_OK;
    return ret;
}
int main(int argc, char *argv[])
{
	unsigned int address;
	char operation;
	Q.begin = 0;
	Q.end = -1;
	presentPages.head = NULL;

	printf("Executando o simulador...\n");

	freopen(argv[2], "r", stdin);
	memset(pageTable, 0x00, 600000*sizeof(tpPage));

	substAlg = uniformizeAlgorithmName(argv[1]);
	pageSize = atoi(argv[3]);
	memSize = atoi(argv[4]);
	pageSizeBitsBoundery = (int) ceil(log2(pageSize*1024));

	while(scanf("%x %c", &address, &operation) != EOF) {
		time++;
		if(time % RECENT_DELTA_TIME == 0) resetRecentUsageBits();
		executeInstruction(address, (operation == 'R' ? 0 : 1));
	}


	printf("Arquivo de entrada: %s\n", argv[2]);
	printf("Tamanho da memoria fisica: %d KB\n", memSize);
	printf("Tamanho das páginas: %d KB\n", pageSize);
	printf("Alg de substituição: %s\n", substAlg);
	printf("Numero de Faltas de Páginas: %d\n", pageFaultCount);
	printf("Numero de Paginas escritas: %d\n", writingCount);
	DEBUG("Numero de Paginas em memória: %d\n", presentCount);

  return 0;
}
예제 #3
0
int main(void)
{
    int maxX, maxY, isLost, scentGrid[MAX_SIZE][MAX_SIZE];
    Robot robot;
    char instruction[MAX_LEN_INSTRUCTION + 1], direction[MAX_LEN_INSTRUCTION + 1];

    memset(scentGrid, 0, MAX_SIZE * MAX_SIZE * sizeof(int));

    scanf("%d %d", &maxX, &maxY);
    while(scanf("%d %d %s", &robot.x, &robot.y, direction) > 0)
    {
        robot.direction = getDirectionInt(direction[0]);

        scanf("%s", instruction);

        isLost = executeInstruction(maxX, maxY, &robot, instruction, scentGrid);

        printf("%d %d %c", robot.x, robot.y, getDirectionChar(robot.direction));
        if(isLost == IS_LOST)
            printf(" LOST");
        printf("\n");
    }

    return 0;
}
예제 #4
0
int executeInstructions(Core *core, int threadId, int instructions)
{
	int i;
	int thread;
	
	core->singleStepping = 0;
	for (i = 0; i < instructions; i++)
	{
		if (core->threadEnableMask == 0)
		{
			printf("Thread enable mask is now zero\n");
			return 0;
		}
	
		if (core->halt)
			return 0;

		if (threadId == -1)	// -1 indicates all threads should execute
		{
			// Cycle through threads round-robin
			for (thread = 0; thread < core->totalThreads; thread++)
			{
				if (core->threadEnableMask & (1 << thread))
				{
					if (!executeInstruction(&core->threads[thread]))
						return 0;	// Hit breakpoint
				}
			}
		}
		else
		{
			if (!executeInstruction(&core->threads[threadId]))
				return 0;	// Hit breakpoint
		}
	}

	return 1;
}
예제 #5
0
파일: Executor.c 프로젝트: UbbeLoL/uVM
void executeFunction(struct FunctionContext *func, struct RuntimeContext *ctx) {
	struct Instruction **opcodes = (struct Instruction**)malloc(sizeof(struct Instruction*) * func->opCount);

	for (int i = 0; i <= func->opCount; i++) {
		opcodes[i] = (struct Instruction*)malloc(sizeof(struct Instruction));
	}

	for (int i = 0; i < func->opCount; i++) {
		if (!readInstruction(func->code, &func->localIp, opcodes[i]))
			break;
	}

	func->next = 0;
	while (executeInstruction(opcodes[func->next], func, ctx)) {
	}
}
예제 #6
0
파일: 6502.c 프로젝트: wcc17/emulate6502OLD
void executeProgram() {
    programCounter = programStart;
    int endOfProgram = 0;

    while(endOfProgram == 0) {
        uint8_t currentInstruction = memory[programCounter++];

        //TODO: get rid of
        int pc_bitch = programCounter;

        if(currentInstruction == 0x00) {
            endOfProgram = 1;
        }
        else {
            executeInstruction(currentInstruction);
        }
    }
}
예제 #7
0
int main(void)
{
	int mRegister[NUM_REGISTER], mRAM[SIZE_RAM], T, numInstruction, isHalt, ind, j,
		programCounter;
	char instruction[LEN_INSTRUCTION + 2], trash[LEN_INSTRUCTION + 2];

	scanf("%d", &T);
	fgets(trash, LEN_INSTRUCTION + 2, stdin);
	fgets(trash, LEN_INSTRUCTION + 2, stdin);

	while(T)
	{
		memset(mRAM, 0, SIZE_RAM * sizeof(int));
		memset(mRegister, 0, NUM_REGISTER * sizeof(int));
		numInstruction = 0;
		isHalt = 0;
		programCounter = 0;
		ind = 0;
		while(1)
		{
			if(fgets(instruction, LEN_INSTRUCTION + 2, stdin) == NULL)
				break;
			if(instruction[0] == '\n' || instruction[0] == '\0')
				break;
	
			for(j = 0; j < LEN_INSTRUCTION; j++)
				mRAM[ind] = mRAM[ind] * 10 + (instruction[j] - '0');
			ind++;
		}
		
		while(!isHalt && programCounter < SIZE_RAM)
		{
			executeInstruction(mRegister, mRAM, &programCounter, &isHalt);
			numInstruction++;
		}

		printf("%d\n", numInstruction);
		if(T != 1)
			printf("\n");
		T--;
	}

	return 0;
}
void GPR_Machine::processInstruction() {
	multicycle = true;
	//determine type of instruction
	instr = m_current_instruction;

	//backups
	latch_fetch_decode_old = latch_fetch_decode_new;
	latch_fetch_decode_new.current_instruction = instr; //set instruction

	latch_decode_execute_old = latch_decode_execute_new;
	latch_decode_execute_new = decode(); //decode

	latch_execute_memory_old = latch_execute_memory_new;
	latch_execute_memory_new = executeInstruction(); //execute

	latch_memory_writeback_old = latch_memory_writeback_new;
	latch_memory_writeback_new = pipelineMemory(); //memory

	//writeback
	int result = writeback(); 
}
예제 #9
0
void CpuRiscV_Functional::updatePipeline() {
    IInstruction *instr;
    CpuContextType *pContext = getpContext();

    if (dport.valid) {
        dport.valid = 0;
        updateDebugPort();
    }

    pContext->pc = pContext->npc;
    if (isRunning()) {
        fetchInstruction();
    }

    updateState();
    if (pContext->reset) {
        updateQueue();
        reset();
        return;
    } 

    instr = decodeInstruction(cacheline_);
    if (isRunning()) {
        last_hit_breakpoint_ = ~0;
        if (instr) {
            executeInstruction(instr, cacheline_);
        } else {
            pContext->npc += 4;
            generateException(EXCEPTION_InstrIllegal, pContext);

            RISCV_info("[%" RV_PRI64 "d] pc:%08x: %08x \t illegal instruction",
                        getStepCounter(),
                        static_cast<uint32_t>(pContext->pc), cacheline_[0]);
        }
    }

    updateQueue();

    handleTrap();
}
예제 #10
0
파일: vm.c 프로젝트: brunzero/P_Machine
int main(int argc, char *argv[])
{
    load();
    output = fopen("stacktrace.txt", "w");

    fprintf(output, "Line  OP    L  M\n");

    printCode(code);

    fprintf(output, "                    pc  bp  sp   stack\n");
    fprintf(output, "Initial values      %d   %d   %d\n", pc, bp, sp);

    while(halt == 0)
    {
        fetchInstruction();
        executeInstruction();
        printInfo();
    }

    fclose(output);
    return 0;
}
예제 #11
0
파일: execute.cpp 프로젝트: gnaghi/bass
bool Bass::execute() {
  stackFrame.reset();
  ifStack.reset();
  ip = 0;
  macroInvocationCounter = 0;

  initialize();

  StackFrame frame;
  stackFrame.append(frame);
  for(auto& define : defines) {
    setDefine(define.name, define.value, true);
  }

  while(ip < program.size()) {
    Instruction& i = program(ip++);
    if(!executeInstruction(i)) error("unrecognized directive: ", i.statement);
  }

  stackFrame.remove();
  return true;
}
예제 #12
0
int main(int argc, char *argv[]) {
    
    
    
    /*These variables are associated with the implementation of the VM*/
    int filePointer;
    int i;
    int curLineNumber = 0;
    char inputInstruction [7];
    int ret;
    
    int x;
    int y;
    for(x = 0; x < 100; x ++) 
	{for(y = 0; y < 6; y ++) 
	{	memory[x][y] = 'X';
	}
	}
    
    //Read file into VM memory. Assume the file name is program2.
    filePointer = open("fib.txt", O_RDONLY);
    printf("Open is %d\n", filePointer) ;
    
    
    
    //If error in read
    if (filePointer < 0)
    {   printf("Could not open file\n");
        exit(0);
    }
    
    
    //read in the first line of the program
    ret = read(filePointer, inputInstruction, 7);
    
    //infinite loop until file contents end
    while (1)
    {
        //end of file or error
        if (ret <= 0)
        {	break;
        }
        
        //copy input line to program memory
        for (i = 0; i < 6 ; i++)
        {	memory[curLineNumber][i] = inputInstruction[i];
        }
        
        //printing out program line for debugging purposes
//        printf("\nProgram Line %d:	", curLineNumber);
//        for(i = 0; i < 6; i++)
//        {	printf("%c", memory[curLineNumber][i]);
//        }
//        printf("\n") ;
        
        //read in next line of program input
        ret = read(filePointer, inputInstruction, 7);
        
        //if the first character is a 'Z' then you are reading data.
        //No more program code so break out of loop
        if(inputInstruction[0] == 'Z')
        {	break;
        }
        
        //increment line
        curLineNumber++;
        
    }
    
    
    
   
    programCounter = 0;
    int exitStatus = 0;
    while (exitStatus == 0)
    {
        
        exitStatus = executeInstruction(memory,programCounter);
        printf("\n");
        
        
    }
    printf("\nFinal VM State\n");
    displayVMStatus();
    
    
}
예제 #13
0
void singleStep(Core *core, int threadId)
{
	core->singleStepping = 1;
	executeInstruction(&core->threads[threadId]);	
}